I made a small Game that frequently needs to change the background. For example setBackgroundDrawableResource(R.drawable.backgroundgame); Now I get the error that I ran out of memory so my question is how do I unload the previous background from the memory?
1
-
Make sure you're setting your 1) calling recycling the image once you're done with it, and/or setting the reference to null. Though not recommended you might find yourself having to invoke the GC.collect() also.BonanzaDriver– BonanzaDriver2011-12-19 14:54:23 +00:00Commented Dec 19, 2011 at 14:54
Add a comment
|
1 Answer
The garbage collector should eventually delete the images when they are no longer needed. It sounds as though you want to call the recycle() method on the bitmap (link) to free up the space more quickly.