我知道使用 jconsole 附加到 java 进程来获取内存信息。具体来说,我正在以编程方式获取有关各种内存池的信息,以便我可以将其绑定到监视应用程序。
Thanks!
谢谢 mattk - 我基本上就是这样做的:-)
List memBeans = ManagementFactory.getMemoryPoolMXBeans();
for (Iterator i = memBeans.iterator(); i.hasNext(); ) {
MemoryPoolMXBean mpool = (MemoryPoolMXBean)i.next();
MemoryUsage usage = mpool.getUsage();
String name = mpool.getName();
float init = usage.getInit()/1000;
float used = usage.getUsed()/1000;
float committed = usage.getCommitted()/1000;
float max = usage.getMax()/1000;
float pctUsed = (used / max)*100;
float pctCommitted = (committed / max)*100;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)