Reputation: 6676
When I write C++ with MS Visual Studio, I use the following statement to check my heap for corruptions. This has been an excellent tool in homing in on problems:
_ASSERTE( _CrtCheckMemory() );
Basically you can scatter the above statement around your code to check the consistency of the heap.
Is there something similar that can be used in Android NDK programs to identify heap corruption at runtime - before I crash with a tombstone dump?
Upvotes: 1
Views: 883
Reputation: 166
In Linux, similar functionality can be achieved by mcheck. But, unfortunately, this can't be used on Android (however, here and here can be find mcheck.h
for Android)
If your device rooted, you can try this:
am dumpheap <pid> <path/where/to/save/dump>
(obtain dump of process's native heap)For dump analyzation, you can try use deprecated Android Monitor (this link should help to enable native heap dump)
Upvotes: 1