Lyn
Lyn

Reputation: 729

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

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 recycle 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?

Upvotes: 1

Views: 1866

Answers (2)

Dmitry Zaytsev
Dmitry Zaytsev

Reputation: 23952

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

Upvotes: 0

Romain Guy
Romain Guy

Reputation: 98501

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

Upvotes: 4

Related Questions