问题
Bitmap has a recycle
method, but do we have to invoke it explicitly if we don't need it any more?
For example, an ImageView
has a bitmap now. When user click a button, it will set a new bitmap to the ImageView.
Do we have to recycle the original bitmap before assign the new one?
回答1:
yes you have if you are targeting devices with Android
older the 3.0
. That's will avoid you to incour in the OutOfMemoryException
.
Note: Before android 3
the Bitmap memory is allocated in the native heap. The java object will retains low memory from the GC perspective.
来源:https://stackoverflow.com/questions/12533001/do-we-have-to-explicitly-recycle-the-bitmap-if-we-dont-need-it