문제

I wonder how can I determine the heap base address and heap size,

I would like to be able to dump my application heap,

Is there any way to do it ?

Plus when I am trying to read the process memory map via /proc/pid/maps, I don't see the [heap] section, why ?

Does the DVM allocate anonymous regions using mmap ?

If yes how can I track them ?

도움이 되었습니까?

해결책

In linux API, you can use showmap to dump the heap size information, and the section is /ashmem/dalvik-heap . And the Android DDMS gives us two tools for analysis the Java heap and Native heap. Java Heap is Android Hprof, and the native heap is the native heap analysis.

다른 팁

I wonder how can I determine the heap base address and heap size,

I would like to be able to dump my application heap,

Is there any way to do it ?

public static void logHeap() {
                Double allocated = new Double(Debug.getNativeHeapAllocatedSize())/new Double((1048576));
                Double available = new Double(Debug.getNativeHeapSize())/1048576.0;
                Double free = new Double(Debug.getNativeHeapFreeSize())/1048576.0;
                DecimalFormat df = new DecimalFormat();
                df.setMaximumFractionDigits(2);
                df.setMinimumFractionDigits(2);

                Log.d("tag", "debug. =================================");
                Log.d("tag", "debug.heap native: allocated " + df.format(allocated) + "MB of " + df.format(available) + "MB (" + df.format(free) + "MB free)");
                Log.d("tag", "debug.memory: allocated: " + df.format(new Double(Runtime.getRuntime().totalMemory()/1048576)) + "MB of " + df.format(new Double(Runtime.getRuntime().maxMemory()/1048576))+ "MB (" + df.format(new Double(Runtime.getRuntime().freeMemory()/1048576)) +"MB free)");
            }

Does the DVM allocate anonymous regions using mmap ?

If yes how can I track them ?

read https://source.android.com/devices/tech/dalvik/index.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top