如何从Java程序中获取JVM的最小和最大堆大小设置 [英] how to get the min and max heap size settings of a JVM from within a Java program
本文介绍了如何从Java程序中获取JVM的最小和最大堆大小设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从Java程序中获取VM的最小和最大堆大小设置?
How to get the min and max heap size settings of a VM from within a Java program?
推荐答案
最大堆大小:
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;
这篇关于如何从Java程序中获取JVM的最小和最大堆大小设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文