Answer the question
In order to leave comments, you need to log in
How to unload image from memory in ImageView on Android 5?
Hello.
I ran into such a problem that I can’t unload images loaded into ImageView on Android 5 from memory.
Before that, I tested it on Android 7 and in the form in which the application is now the memory is consumed slightly, but on Android 5 it just leaks through your fingers.
There is a method through which I unload a picture from memory, I wrote the following in it:
cardview_tumbnile_imageview.setImageResource(0);
cardview_tumbnile_imageview.setImageBitmap(null);
cardview_tumbnile_imageview.setImageDrawable(null);
System.gc();
setImageDrawable(null)
Answer the question
In order to leave comments, you need to log in
First, gc is run as the hip is exhausted. And if a lot of pictures do not cause OutOfMemory, then it is better to leave this optimization for later.
Secondly, if your images are not prepared for different resolutions, then it makes sense to load them via Bitmap.createScaledBitmap(). This will reduce memory consumption.
Did Dump Memory Heap and saw a bunch of byte[] there after loading images
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question