Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

My Java game fills the system memory [closed]

$
0
0

edited.
I am writing my first game using LIBGDX.
The issue I’m having is that the system memory completely fills up and then even the swap file starts to grow.
From what I see, the memory fills pretty evenly. So it is not one level that has a huge increase of memory usage. As the game moves from level 1 to 2 and so on, the memory usage just keeps going up by a similar amount each time.
I have every arraylist that I use, make sure that it is empty before the level will be declared done and move on to the next so I’m not sure if it is possible that references to objects are being kept.
I have each level set as its own state that gets called by a game state manager and the old level gets set to null, which I thought would allow the java garbage collector to free it from memory. Perhaps this is not happening though.
Basically how can I free up the memory?
Is declaring a state to null, not the proper way to get the java garbage collector to remove it?
Also is it wrong or bad coding design to have each game level as its own state?


Viewing all articles
Browse latest Browse all 434

Trending Articles