I'm trying to better understand how Android handle images in order to use memory more efficiently. I have an image stored in the Bitmap
and I'm using ImageView.setImageBitmap()
to display it. Now the question is - will it use the Bitmap
I've passed it in the future, or it's making a copy of it and the Bitmap
I've created isn't used anymore after the call to setImageBitmap
?
Asuming it's gonna keep reference to the Bitmap
I've passed, how is it gonna behave when Bitmap
was created via BitmapFactory
using inPurgeable
option? Will ImageView
prevent the Bitmap
from being temporarily purged from the memory? Is it gonna happen only when ImageView
has View.VISIBLE
state, or also when View.GONE
and View.INVISIBLE
? Or maybe only while ImageView
is visible on the screen?
And one more thing - looking through Android source code reveals that encoded byte data is always copied into memory (inInputShareable
is currently ignored). Is it counted towards the 16/24MB memory limit for android Java application?
Thanks