0

I am developing one android application which is using more images with resolution 640*960 approximately. all these images are loaded with bitmaps with proper scaling factor.

When i am loading bitmpas heap size is increasing and it is not decreasing even though i am recycling the bitmpas. as i read few theory's regarding this issue maximum says once heap increased it will not decreased at all.

My problem is if i close my application when heap size is 10MB , and when i reopen the application heap is starts from 10Mb. it causes VM exceeds Maximum heap memory and then Out Of Memory after some time.

what i have to do for this, and i am guarantee that my application will never close with out recycling bitmaps.

can any one please suggest me how to minimze the heap memory and solve this OOM.

tshepang
  • 12,111
  • 21
  • 91
  • 136
user1430138
  • 11
  • 1
  • 6
  • Do one thing one you re open the app again then free the 10MB. Read this http://android-sample-code.blogspot.in/2012/01/how-to-clear-cache-data-in-android.html – Ajay S Feb 05 '13 at 16:02
  • http://stackoverflow.com/questions/3117429/garbage-collector-in-android Should help – smk Feb 05 '13 at 16:02

1 Answers1

0

Even i faced the same problem....you can refer this link for effectively loading the bitmaps http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

Once heap size has exceeded the limit your garbage collector runs...and it cleans up any unwanted object.so its better not to call garbage collector as it will run automatically.

Applications running on API Level 11+ can have android:largeHeap="true" on the element in the manifest to request a larger-than-normal heap size

In your onCreate method in your activity you can use this(i did'nt try this) dalvik.system.VMRuntime.getRuntime().setMinimumHeapSize(yournumberhere);

Srikanth Roopa
  • 1,782
  • 2
  • 13
  • 19