We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
对于线程转储,您可以使用 JConsole、VisualVM,或者更简单地,向目标进程发送 QUIT 信号
,或者
从 Java 5 开始,还有
jstack
它是独立于平台的,并且有一个很好的-m
选项来打印 Java 和本机帧(混合模式) )。使用 Sun VM、
jmap
、Sun JConsole、Sun VisualVM、SAP JVMMon。对于 IBM VM,请检查此页面。实际上,Eclipse MAT wiki 有一个很好的 获取堆转储 部分,总结了所有内容选项。对于线程转储,我使用 TDA - 线程转储分析器(适用于 Sun JDK)和 IBM 线程和监视器转储分析器(适用于 IBM JDK)。 Samurai 也非常好(它的工作方式类似于
tail -f
并自动从 std/stderr 中获取线程转储,它还可以读取“-verbose:gc”日志)并且已经针对来自 Apple、BEA、HP、Sun 和 IBM 的 VM 进行了测试(还可以读取 IBM 的 javacore) )。对于堆转储,我使用 VisualVM (对于 Sun JDK)或 IBM Heap Dump Analyzer(仅适用于 IBM JDK)或 über Awesome Eclipse MAT 根据我的需要。后者能够使用 HPROF 二进制堆转储(由 Sun、HP、SAP 等 JVM 生成)、IBM 系统转储(预处理后)以及来自各种类型的 IBM 便携式堆转储 (PHD) IBM 平台)。
For a thread dump, you can use JConsole, VisualVM or, more simply, send a QUIT signal to the target process
or
Since Java 5, there is also
jstack
which is platform independent and has a nice-m
option to print both Java and native frames (mixed mode).With Sun VMs,
jmap
, Sun JConsole, Sun VisualVM, SAP JVMMon. For IBM VMs, check this page. Actually, the Eclipse MAT wiki has a nice Getting a Heap Dump section summarizing all the options.For thread dumps I use TDA - Thread Dump Analyzer (for Sun JDKs) and IBM Thread and Monitor Dump Analyzer (for IBM JDKs). Samurai is also very nice (it works like a
tail -f
and picks up thread dumps from your std/stderr automatically, it can also read "-verbose:gc" logs) and has been tested against VMs from Apple, BEA, HP, Sun and IBM (can also read IBM's javacore).For heap dumps, I use VisualVM (for Sun JDKs) or IBM Heap Dump Analyzer (only for IBM JDKs) or the über awesome Eclipse MAT depending on my needs. The later is able to work with HPROF binary heap dumps (produced by Sun, HP, SAP, etc... JVMs), IBM system dumps (after preprocessing them), and IBM portable heap dumps (PHD) from a variety of IBM platforms).
假设 JDK 6,请查看以下文章以获取正在运行的程序的线程转储:
http://java.sun.com/developer/technicalArticles/Programming/Stacktrace/
可以使用JHat进行堆分析:
http://java.sun.com/javase/6/docs/technotes/tools/share/jhat.html
如果你想做内存转储看看jmap:
http://java.sun.com/javase/6/docs/technotes/tools/share/jmap.html
或者,如果您需要进行更深入的分析,请查看分析器,例如 Yourkit:
< a href="http://www.yourkit.com/" rel="nofollow noreferrer">http://www.yourkit.com/
Assuming JDK 6, Take a look at the following article to obtain thread dumps of a running program:
http://java.sun.com/developer/technicalArticles/Programming/Stacktrace/
You can use JHat to do heap analysis:
http://java.sun.com/javase/6/docs/technotes/tools/share/jhat.html
If you want to do memory dumps take a look at jmap:
http://java.sun.com/javase/6/docs/technotes/tools/share/jmap.html
Alternatively, if you need to do some more in depth analysis look at a profiler such as Yourkit:
http://www.yourkit.com/
还有两件事您可能会感兴趣:
There's also these two things that can interest you:
JVM 没有标准工具集。这些取决于供应商,您应该查阅文档。
对于 Sun Java 6,VisualVM 程序对于获取正在运行的程序的快速分析和堆栈跟踪非常非常有帮助。
There is no standard toolset for JVMs. These are vendor dependant, and you should consult the documentation.
For Sun Java 6 the VisualVM program is very, very helpful to get a quick profile and stack trace of a running program.
我用于调试 Sun JVM 的工具是
The tool I use for this kind of debugging a Sun JVM are
我认为在生产环境中调试java应用程序的最佳方法不是转储等,而是对日志进行良好的管理。
例如,请参见 slf4j。
And I think the best way to debug java application in production environment is NOT dump and so on, but a good managment of logs.
See for instance slf4j.
要调试内存分配问题,可以在命令行使用 InMemProfiler。可以跟踪实时分配与收集分配,并且可以根据收集的对象的生命周期将其分成存储桶。
在跟踪模式下,此工具可用于识别内存分配的来源< /a>.
To debug issues with memory allocations, InMemProfiler can be used at the command line. Live vs collected allocations can be tracked and collected objects can be split into buckets based on their lifetimes.
In trace mode this tool can be used to identify the source of memory allocations.