Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have developed and launched a game called Bicycle Doodle GLD.

In this game, I load all the game resources at the initial loading scene. The game contains 24 levels, so only the resources that change for each level I don't load initially, but instead load at the level-select scene. Each level needs 5 to 15 terrain images that load during level selection time. There are the following scenes in the game: menu scene, level select scene, game play scene, and game over scene.

On each set of scene I call System.gc(), so memory clean up occur. My problem is that after playing a long time and changing scenes, the game suddenly closes without firing any message in debug.

I think memory becoming full is the reason. How do I fix this?

share|improve this question
I have found a link that talk about the similar problem that I have faced right now. I want to know that unloading texture manager work or not? Although there is a method in andengine gles2 to unload texture atlas. Another solution I found is suggested in following link… So guys please suggest me what is the right way? – Siddharth Feb 24 '13 at 3:27

You need to profile your code and find what's taking up so much memory. Simply calling the garbage collection won't get rid of things that you've forgotten to stop using properly. Check out Traceview for a tool that comes with the SDK. Or search for your own Android profiler to find what's using your memory.

Once you have your memory usage statistics, you can find the parts of your code that use too much memory. Optimize those parts.

share|improve this answer

If you haven't already I would recommend looking at this video on memory management for Android apps. This gives a great overview of the Dalvik GC, and its basis in mark and sweep. It also shows some of the tools and abilities, even though its over a year old its a fantastic video.

Also, just calling System.gc() sends a suggestion to the Dalvik GC to try and release any marked memory for deletion. Of course at this point you may not have setup the rest of your program correctly to release resources, this is why as you continue to try and play it gets worse. In fact, the video specifically says you should avoid calling this method and just trust in the garbage collector, this is standard JAVA practice as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.