I’d like to create a thread that keeps track of the memory usage and cpu usage.
If the application reaches a high level, I want to generate an heap dump or a thread dump.
Is there a way to generate a Thread dump runtime without restarting?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s how we do it programmatically: http://pastebin.com/uS5jYpd4
We use the
JMXThreadMXBeanandThreadInfoclasses:You can also do a
kill -QUIT pidunder ~unix to dump the stacks to the standard-out. There is also jstack to dump the stack of a JVM.We also have an automation which dumps the stack if the load average of the application is above some threshold: