This is a nice trick I learned over the past week while doing JVM heap analysis. You can use JConsole to take a heap dump of your JVM
. Open the MBeans tab
and navigate to com.sun.management
, then HotSpotDiagnosticMXBean
. This will display all the methods that can be invoked on this bean. We're interested in the dumpHeap
The JDK documentation
describes this method as:
So the first parameter is the file name to write the heap dump to and the second controls whether all objects or just the live objects are to be dumped. If you specify false
, it will include all objects that are not reachable and are waiting to be garbage collected, otherwise it will only include just the reachable objects.
Hope you found this post useful...
...so please read on! I love writing articles that provide beneficial information,
tips and examples to my readers. All information on my blog is provided free of
charge and I encourage you to share it as you wish. There is a small favour I ask in return however -
engage in comments below, provide feedback, and if you see mistakes let me know.
If you want to show additional support and help me pay for web hosting and
domain name registration,
donations, no matter how small, are always welcome!
Use of any information contained in this blog post/article is subject to this disclaimer
Other posts you may like...