如何动态监控Java堆大小? [英] How to dynamically monitor Java heap size?
本文介绍了如何动态监控Java堆大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试动态监视java堆大小。有人知道如何在运行一段代码的过程中获得最大内存吗? Runtime.maxMemory()可以解决这个问题吗?谢谢
I am trying to monitor the java heap size dynamically. Does anybody know how to get the maxmium memory used in the process of running a piece of codes? Does the Runtime.maxMemory() do the trick? Thanks
推荐答案
maxMemory()
返回java将使用的最大内存量使用。所以那不会得到你想要的东西。 totalMemory()
就是你要找的东西。请参阅文档
这篇关于如何动态监控Java堆大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文