简体   繁体   English

在负载下收集Java heapdump

[英]Collecting Java heapdump under load

I am running load against Tomcat 6 running on Java 6. I want to collect a heapdump of the Java heap while the Tomcat server is under load. 我正在针对在Java 6上运行的Tomcat 6运行负载。我想在Tomcat服务器负载下收集Java堆的heapdump。 I normally use jmap -dump to collect my heapdumps. 我通常使用jmap -dump收集我的heapdumps。

However, when I try to do this when Tomcat is handling a high load I find that the heapdump collection fails. 但是,当我尝试在Tomcat处理高负载时执行此操作时,我发现heapdump收集失败。

Is jmap the best tool for collecting a heap dump from a process under load? jmap是从负载下的进程收集堆转储的最佳工具吗? What are the possible causes which would cause jmap to fail to collect a heapdump? 有哪些可能的原因会导致jmap无法收集堆转储?

If jmap is not the best tool - what is better? 如果jmap不是最好的工具-哪个更好?

It is entirely acceptable to me for jmap (or some other tool) to stop the world within the Java process while the heap dump is taken. 对于jmap(或其他工具)来说,在进行堆转储时停止Java进程中的世界对我来说是完全可以接受的。

Is jmap the best tool for collecting a heap dump from a process under load? jmap是从负载下的进程收集堆转储的最佳工具吗?

I think: No it isn't. 我认为:不,不是。 From this link : 从此链接

NOTE - This utility is unsupported and may or may not be available in future versions of the JDK. 注意-此实用程序不受支持,在JDK的将来版本中可能可用,也可能不可用。

I've also found jmap can pretty temperamental. 我还发现jmap很有气质。 If you're having problems: 如果您遇到问题:

  • Try it again. 再试一遍。 It often manages to get a heap dump after a couple of attempts if it first fails 如果它第一次失败,经过几次尝试,它通常会设法获得堆转储
  • Use the -F option 使用-F选项
  • Add -XX:+HeapDumpOnOutOfMemoryError as a standard configuration to proactively take heap dumps when an OOM error is thrown 添加-XX:+ HeapDumpOnOutOfMemoryError作为标准配置,以在抛出OOM错误时主动进行堆转储
  • Run Tomcat interactively and add the heap dump on ctrl-break option. 交互式运行Tomcat,并在ctrl-break选项上添加堆转储。 This gives you a thread dump too, something you'll probably need anyway 这也为您提供了一个线程转储,无论如何您可能仍需要
  • If your heap size is especially large and you have a repeatable condition, temporarily lower your heap size. 如果您的堆大小特别大且情况可重复,请暂时减小堆大小。 It makes the resulting file much easier to handle, takes less time and is more likely to succeed 它使生成的文件更易于处理,花费的时间更少,并且更有可能成功

I have found that running Tomcat with a JMX port allows me to take a remote heapdump using visualvm. 我发现使用JMX端口运行Tomcat允许我使用visualvm进行远程堆转储。 This succeeded for me when jmap failed. 当jmap失败时,这对我来说成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM