Java 如何监控 JVM 或 Eclipse 中的线程和内存使用量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9731849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 06:51:13  来源:igfitidea点击:

How can I monitor how many threads and memory usage in my JVM or Eclipse?

javaeclipsemultithreadingmemory

提问by DNB5brims

I want to monitor the memory usage and threading, how can I do on the Eclipse or JVM? Thanks.

我想监控内存使用和线程,我在 Eclipse 或 JVM 上怎么做?谢谢。

回答by Geek

in Eclipse, run the program in debug mode (this will also open the debug perspective). In that you can see how many threads are running. The best tool for this could be an inbuilt profiler . I guess JVM has a profiling tool as well or you can use third party profiling tool like JProfiler or yourkit. http://www.yourkit.com/

在 Eclipse 中,以调试模式运行程序(这也将打开调试透视图)。在那里你可以看到有多少线程正在运行。最好的工具可能是内置的分析器。我猜 JVM 也有分析工具,或者您可以使用第三方分析工具,如 JProfiler 或 yourkit。 http://www.yourkit.com/

回答by Mavlarn

You can try jvisualvm.exeYou can find it in jdk/bin directory. It's great tool. Read hereon the usage of it.

你可以试试jvisualvm.exe你可以在 jdk/bin 目录中找到它。这是一个很棒的工具。在这里阅读它的用法。

If you want to get the status in your java code, you can try JMX. Google the keywords "JMX Monitoring and Management".

如果你想在你的java代码中获取状态,你可以尝试JMX。谷歌搜索关键字“JMX 监控和管理”。

回答by Ingo Kegel

JProfilerprovides a lot of useful information on threading and monitor contention and it has an eclipse plugin.

JProfiler提供了很多关于线程和监视器争用的有用信息,并且它有一个 eclipse 插件。

See these screen casts for monitor contention analysis:

请参阅以下屏幕截图以进行监视器争用分析:

Disclaimer: My company develops JProfiler

免责声明:我公司开发JProfiler