开发者

Android Bitmap recycle question, do I need to maintain all the references of Bitmap, to call recycle method?

开发者 https://www.devze.com 2023-02-16 21:50 出处:网络
Frequently we get image from server as byte stream, then we create Bitmap and assign it to ImageView object.

Frequently we get image from server as byte stream, then we create Bitmap and assign it to ImageView object.

When I need to release memory, I can drop all ImageView references to null, letting the gc do the work.

But question is, in this way, I did not call the r开发者_运维技巧ecycle method of Bitmap since I did not keep references of it. So I wonder that, do I need to maintain all the references of Bitmap, to recycle them in the future?


No you don't need to, the GC will do it for you.


It's better to do so, because Bitmap object itself is poor candidate for GC (since memory allocated in native heap).

Also you should recycle your ImageView bitmap, before using the new one

Recycle ImageView's Bitmap

0

精彩评论

暂无评论...
验证码 换一张
取 消