Android OutOfMemory and LruCache Error

Firstly, I know that there are many related posts, I read a lot of them, none of them helped, and I have no ideas :)

So, I am developing an Android application (sdk version 14+) that uses a lot of images (for buttons, logos, displaying a large number of images, etc.). The average image size is 120kb + - 100kb

As the header says, I get an OutOfMemory error. First I added the image source to ImageViews in xml or programmatically using setImageResource. Soon, the application started crashing due to an OutOfMemory error. So I read this ( http://developer.android.com/reference/android/util/LruCache.html ) and implemented LruCache as it says. I added bitmaps to lrucache and then used the get method to set the bitmap to imageview.

In the onDestroy method, I call the evictAll method on lrucache, and I set lrucache to null. Therefore, I assume that memory is freed.

However, the problem still persists, when I look through a couple of actions, the application crashes.

Help evaluate!)

+5
source share
3

, VM, OutOfMemory. , .

, .

 bitmap.recycle();

LRUCache?. .

, LRUCache , , . ( )

, ( commomsware).

http://www.youtube.com/watch?v=_CruQY55HOk. , MAT Analyzer.

+3

, , !

, - , :

  • .recycle() , .
  • Eclipse Memory Analyzer, .
  • () .
  • , .hprof .
+4

? , SD- ( LRU).

... .

http://www.eclipse.org/mat/

OutOfMemoryError .

!

+1
source

All Articles