I have a big bitmap, created with
Bitmap.createBitmap(). Is there any sense in writing
bitmap = null;
bitmap = Bitmap.createBitmap();
to let the GC use the memory occupied with the old bitmap while constructing the new bitmap.
The API level is 11.
Gracias por su atención.
preguntado el 09 de septiembre de 13 a las 10:09
bitamp = null; will not ensure that GC will release the memory occupied by bitmap object. Brcause
as Bitmap is a final class so priority of final object is very low for GC. Use
bitmap.recycle() method to ensure for Garbage collection(GC).
Look at the video around 11:23. The guy talks about bitmap memory management
Its left to the garbage collector to free memory. Instead of
bitmap = null utilizan el
bitmap.recycle() on andorid 2.3.3 and lower. Use
BitmapFactory.Options.inBitmap on 3.0 and higher
On android 2.3.3 and lower
On Android 2.3.3 (API level 10) and lower, using recycle() is recommended. If you're displaying large amounts of bitmap data in your app, you're likely to run into OutOfMemoryError errors. The recycle() method allows an app to reclaim memory as soon as possible.
On android 3.0 and higher
The bitmap pixel data is stored on the heap
Android 3.0 (API Level 11) introduces the BitmapFactory.Options.inBitmap field. If this option is set, decode methods that take the Options object will attempt to reuse an existing bitmap when loading content. This means that the bitmap's memory is reused, resulting in improved performance, and removing both memory allocation and de-allocation.
Also check this might help