LibGDX - Memory clean-up?

Hi,

Can I clean up the memory or so in LibGDX? If I play my game on my little android phone it works good, but after 1 game the game stops displaying images, I know this is because of the memory is full, because I checked my desktop and I saw the more screens I opened, the fuller the memory became, and after some games, the game was already taking 300 MB memory on my PC (while my mobile has only 128 MB)…

Thanks in advance!

Do you call

.dispose()

on your LibGDX objects? In the dispose method of your classes, you should call dispose on your texture objects and your batches etc… to clean up your memory.

Thanks, Im still LibGDX-n00bie, sorry, I never used libraries before (started 6 weeks ago with using LibGDX :P)

No problem I’m in the same boat! Just started 2 weeks ago and I still feel like a major newbie :slight_smile:
Good luck!

Watch out on using dispose(), you should only call it on resources that you really want to throw out. For example if you disposed a shared SpriteBatch or Texture, expect a good time.

I did as you instructed and disposed my shared texture, good time was not had. You are a mean, mean, person.

You can make this a bit easier by using AssetManager for all your assets.

I found out today it’s more dangerous to not understand sarcasm than anything else :slight_smile:

AssetManager is your best bet. Using this you only need call dispose once-when completely exit the game (not just changing screen).