Skip to content Skip to sidebar Skip to footer

Out Of Memory In Thread Repeatition?

friends, i am using following code to display single full screen image in activity using thread problem scenario is from custom image gallery on each thumbnail clicking displays la

Solution 1:

Bitmaps are the most annoying thing to manage with Android.

To avoid most of the OOM exception I use :

//Try to free up some memory
System.gc();
System.runFinalization();
System.gc();

Yes you read right 2 system.gc...Go figure :s

Just before trying to decode it. So in your case it would be before the setImageBitmap I presume. But look into your logcats and put it just before the line that makes your app crashes.

If it still happen try to open a smaller version of your bitmap by using bitmapOtions.insamplesize when you allocate your bitmap.

Solution 2:

Are you running the debugger when the out of memory error occurs? If so, then the debugger might be the source of the problem. If you run the app under the debugger, then any threads created will still be retained by the debugger, even when they're finished running. This leads to memory errors that won't occur when the app is running without the debugger. Try running without the debugger to see if you still get the memory leak.

http://code.google.com/p/android/issues/detail?id=7979

https://android.googlesource.com/platform/dalvik/+/master/docs/debugger.html

If this isn't the case, then try using the Eclipse Memory Analyzer to track down what the memory issue might be. http://www.eclipse.org/mat/

Post a Comment for "Out Of Memory In Thread Repeatition?"