In libgdx I used to release all resources such as textures, audio resources and also world object.As I have lot textures, drawbles in my game. Managing with textures and sound resources has been released by calling dispose(). But the problem still recurring and heap size is getting increased. Possibly at a certain point VM can not allocate the memory for process if it exceeds maximum size, finally result is OutOfMemory. Please help me to come out from this.App flow
- Home Activity renders to another Activity which extends AndroidApplication(application listener).
- In that i am calling application listener in onCreate() by initializing listener here.
- Passing some game data to listener along with context.
If you are using the Bitmap class, then you might want to check that you are calling recycle on each one before disposing. This fixed many of my memory problems.
Docs on Bitmap and recycle() can be found here
http://developer.android.com/reference/android/graphics/Bitmap.html
If that doesn’t help then you are going to have to describe a bit more how the application is structured. Perhaps you have errant threads or something that are eating up resources. What tools are you using to diagnose your memory issues?