Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HEAP MEMORY CORRUPTION IN dlmalloc or dlfree and SIGSEGV errors in Android ICS 4.0

Since I couldn't find anyone reporting this behaviour before I thought about posting the problem and my solution here so it could help others who are having this problem. Our app did work great on devices prior to ICS. We tested our app on the Galaxy Nexus and the ICS emulator and saw weird process crashes of the following kind:

HEAP MEMORY CORRUPTION IN dlmalloc

HEAP MEMORY CORRUPTION IN dlfree

signal 11 (SIGSEGV), fault addr deadbaad

The problem is that the crashes occured in the native space so there wasn't any self written code which affected it directly. Since we handle a lot of images in lists and the system allocates bitmaps for those the only thing which came to mind was some bad bitmap handling. We followed all best practices out in the web and we even helped the GC to collect unneeded resources by calling bitmap.recycle(). Anyway, for some unknown reason the application crashed constantly on Android ICS 4.0.

like image 888
MarioB. Avatar asked Dec 08 '11 12:12

MarioB.


1 Answers

After some investigation I removed the call to recycle() and everything works out great now. It seems that the garbage collector in ICS already clears the bitmaps correctly. Our call to recycle() caused the system to attempt to deallocate the memory in the native space but the memory was already cleared by the system. Somehow bad memory access occured and the system crashed. So if you are programming for Android ICS 4.0 and you are experiencing those problems, you might want to try without recycling your bitmaps explicitly.

like image 182
MarioB. Avatar answered Oct 02 '22 15:10

MarioB.