简体   繁体   English

Dalvik堆大小和堆基

[英]Dalvik heap size and heap base

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 ? 另外,当我尝试通过/ proc / pid / maps读取进程内存映射时,看不到[heap]部分,为什么?

Does the DVM allocate anonymous regions using mmap ? DVM是否使用mmap分配匿名区域?

If yes how can I track them ? 如果是,我如何跟踪它们?

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 ? DVM是否使用mmap分配匿名区域?

If yes how can I track them ? 如果是,我如何跟踪它们?

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

In linux API, you can use showmap to dump the heap size information, and the section is /ashmem/dalvik-heap . 在linux API中,可以使用showmap转储堆大小信息,该部分为/ ashmem / dalvik-heap And the Android DDMS gives us two tools for analysis the Java heap and Native heap. Android DDMS为我们提供了两个工具来分析Java堆和本机堆。 Java Heap is Android Hprof, and the native heap is the native heap analysis. Java Heap是Android Hprof,本机堆是本机堆分析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM