我想知道如何确定堆基地址和堆大小,
我希望能够转储我的应用程序堆,
有什么办法吗?
另外,当我试图通过/proc/pid/ map读取进程内存映射时,我没有看到堆部分,为什么?
DVM是否使用mmap分配匿名区域?
如果是的话,我怎么能追踪到他们?
发布于 2014-04-12 16:13:07
在linux中,可以使用showmap转储堆大小信息,部分是/ashmem/dalvik-堆。Android为我们提供了两个分析Java堆和本机堆的工具。Java是Android,本机堆是本机堆分析。
发布于 2014-04-06 19:20:14
我想知道如何确定堆基地址和堆大小, 我希望能够转储我的应用程序堆, 有什么办法吗?
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)");
}DVM是否使用mmap分配匿名区域? 如果是的话,我怎么能追踪到他们?
https://stackoverflow.com/questions/22898610
复制相似问题