In Android, when I inspect application memory using adb shell dumpsys meminfo
, I observe separate Java and native heaps, but only 1 entry for stack.
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 4516 4480 0 1848 11520 7412 4107
Dalvik Heap 9726 9668 0 12924 33436 28477 4959
Dalvik Other 1417 1416 0 28
Stack 288 288 0 0
I want to ask whether in Android, when a java class uses native code via JNI, is the native stack allocated in contiguous memory location from the java stack, or are they non-contiguous (really two separate stacks) ?
From a description of the JVM, it appears that the java stack and native stack are contiguous (but I can't confirm that this image indeed indicates that, or just the page author drew them next to each other).
Also, does anyone have a picture that shows how memory management is done in Dalvik/ART ? I know several SO questions exist, but I still cannot get a good understanding, specifically for:
- Difference between java stack/heap and native stack/heap
- Shared library locations