java - Canvas.drawBitmap() and freeing up memory -
i have listview
, items in list custom view
s. view
class has field
private bitmap bitmap;
and ondraw
method of view
uses
canvas.drawbitmap(bitmap, matrix, paint);
the trouble geting outofmemoryerror
s. want free memory associated bitmap
when item scrolls off screen. thought write bitmap = null
allow garbage collector take bitmap
, worried canvas.drawbitmap
might mean doesn't work. canvas.drawbitmap
hold onto reference bitmap
? or call canvas.drawbitmap
mean canvas
object has memory bitmap
? trouble don't understand canvas
is, , various draw
calls do. thank help.
if you're displaying large amounts of bitmap data in app, you're run outofmemoryerror errors. recycle() method allows app reclaim memory possible.
however if call recycle() , later attempt draw bitmap, error: "canvas: trying use recycled bitmap".
but need extensive reading of the android's site training on managing bitmap memory have different strategies according api use.
take @ whole guide of displaying bitmaps efficiently . contains can need keeping down memory usage:
- loading large bitmaps efficiently
- processing bitmaps off ui thread
- caching bitmaps
- managing bitmap memory - answered bitmap memory reclaim
- displaying bitmaps in ui
if follow guidelines should able rid of memory leaks , improve user experience.
does canvas.drawbitmap hold onto reference bitmap? or call canvas.drawbitmap mean canvas object has memory bitmap?
the canvas holds reference bitmap phrased it.
a canvas works pretense, or interface, actual surface upon graphics drawn — holds of "draw" calls. via canvas, drawing performed upon underlying bitmap, placed window. canvas draw onto defined bitmap.
Comments
Post a Comment