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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top