-Xmxsize
Specifies the maximum size (in bytes) of the memory allocation pool in bytes.
-XX:NewRatio=old/young By default, this option is set to 2.
-XX:SurvivorRatio=eden/survivor By default, this option is set to 8.
-Xmx3212M -XX:NewRatio=3 -XX:SurvivorRatio=9
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage();
System.out.println(heapMemoryUsage);
for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
if(MemoryType.HEAP.equals(memoryPoolMXBean.getType())) {
System.out.println(memoryPoolMXBean.getName()+"\t"+memoryPoolMXBean.getUsage());
}
}
init = 134217728(131072K) used = 1698944(1659K) committed = 131596288(128512K) max = 3291480064(3214336K)
PS Eden Space init = 28311552(27648K) used = 1698944(1659K) committed = 28311552(27648K) max = 836763648(817152K)
PS Survivor Space init = 2621440(2560K) used = 0(0K) committed = 2621440(2560K) max = 2621440(2560K)
PS Old Gen init = 100663296(98304K) used = 0(0K) committed = 100663296(98304K) max = 2526019584(2466816K)
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.