java - Canvas.drawBitmap() and freeing up memory -


i have listview , items in list custom views. view class has field

private bitmap bitmap; 

and ondraw method of view uses

canvas.drawbitmap(bitmap, matrix, paint); 

the trouble geting outofmemoryerrors. 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:

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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -