0

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. Commented Dec 19, 2011 at 14:54

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.