简体   繁体   English

如何在 Mac 中获取 Tomcat 的堆转储和线程转储

[英]How do get heap dump and thread dump for Tomcat in Mac

I am trying to analyize the memory usage for a application that is being deployed in Tomcat.我正在尝试分析部署在 Tomcat 中的应用程序的内存使用情况。

I need to get the heap dump and thread dump while the application is running in tomcat.当应用程序在 tomcat 中运行时,我需要获取堆转储和线程转储。

Can anybody let me know how to get those dumps in mac from terminal for Tomcat.任何人都可以让我知道如何从 Tomcat 的终端获取 mac 中的这些转储。

I tried getting tomcat PID using "ps ux | grep apache" and then did "kill -3 PID", but nothing happens...我尝试使用“ps ux | grep apache”获取 tomcat PID,然后执行“kill -3 PID”,但没有任何反应...

it depends on the JVM you use to run your Tomcat.这取决于您用来运行 Tomcat 的 JVM。 I strongly recommend to run all applications and servers using the JDK (in case of HotSpot, which you likely use).我强烈建议使用 JDK 运行所有应用程序和服务器(在您可能使用的 HotSpot 的情况下)。 Then you should have multiple utilities at hand:那么你应该手头有多个实用程序:

  • jps - for finding your pid jps - 用于查找您的 pid
  • jstack - for getting thread dump jstack - 用于获取线程转储
  • jmap - for getting the heap dump. jmap - 用于获取堆转储。

or you use jvisualvm which bundles all the tools into a nice ui.或者您使用 jvisualvm 将所有工具捆绑到一个漂亮的用户界面中。 Last, but not least, it is possible that you have gotten the wrong PID :-)最后但并非最不重要的是,您可能获得了错误的 PID :-)

执行 kill -3 PID 后,Apache Tomcat 的 PID 进程 id 在哪里,线程转储将写入 /tomcat/logs/catalina.out

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

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