Pergunta

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 ?

Foi útil?

Solução

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.

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top