My Android game runs out of memory when it is closed and opened and couple times.

Posted by sirconnorstack on Stack Overflow See other posts from Stack Overflow or by sirconnorstack
Published on 2010-05-21T19:58:42Z Indexed on 2010/05/21 20:20 UTC
Read the original article Hit count: 168

Filed under:
|
|
|
|

I have an Android game that has an activity for the menu, and then another activity for the game that creates a SurfaceView and Thread to deal with canvas drawing and game logic. When you exit the game and start it up again too much or if you open and close the keyboard (thus restarting the activity), the game runs out of memory, usually when loading a bitmap:

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

How can I keep all my images in memory without loading them again when the game changes state, or how can I release them from memory and let them reload when the game is restarted?

© Stack Overflow or respective owner

Related posts about android

Related posts about memory