我想我在 NetBeans 中将堆大小增加到 1 GB,因为我将配置更改为如下所示:
netbeans_default_options="-J-Xmx1g ......
重新启动 NetBeans 后,我能否确定我的应用程序现在已获得 1 GB 空间?
有没有办法验证这一点?
使用此代码:
// Get current size of heap in bytes
long heapSize = Runtime.getRuntime().totalMemory();
// Get maximum size of heap in bytes. The heap cannot grow beyond this size.// Any attempt will result in an OutOfMemoryException.
long heapMaxSize = Runtime.getRuntime().maxMemory();
// Get amount of free memory within the heap in bytes. This size will increase // after garbage collection and decrease as new objects are created.
long heapFreeSize = Runtime.getRuntime().freeMemory();
了解它对我很有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)