开发者

how to get the min and max heap size settings of a JVM from within a Java program

开发者 https://www.devze.com 2022-12-19 20:41 出处:网络
How to get the min and max heap size settin开发者_如何学Pythongs of a VM from within a Java program?max heap size:

How to get the min and max heap size settin开发者_如何学Pythongs of a VM from within a Java program?


max heap size:

Runtime.getRuntime().maxMemory();

Some other calculations which you may find interesting:

Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
long totalFreeMemory = freeMemory + (maxMemory - allocatedMemory);
long usedMemory = maxMemory - totalFreeMemory;


You just need to use the Runtime object with Runtime.getRuntime() and then use methods like totalMemory() and freeMemory().


maybe that could help you ?

http://download.oracle.com/docs/cd/E11035_01/wls100/perform/JVMTuning.html#wp1109778 http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html http://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp http://blog.paulgu.com/2008/07/19/6-common-errors-in-setting-java-heap-size/


ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号