[ACCEPTED]-How can I take a heap dump on Java 5 without garbage collecting first?-heap-memory
use jconsole or visualvm or jmc or ... other 7 jmx management console. open HotSpotDiagnostic 6 in com.sun.management. select method dumpHeap and 5 input two parameters:
- path to the dump file
- (true/false) dump only live objects. use
false
to dump all objects.
Note that the dump 4 file will be written by the JVM you connected 3 to, not by JVisualVM, so if the JVM is running 2 on a different system, it will be written 1 on that system.
Have you tried the standard jmap tool shipped 5 with the JDK? The jmap toll was officially 4 introduced in Java 5.
Example command line: /java/bin/jmap 3 -heap:format=b
The result can be processed 2 with the standard jhat tool or with GUI 1 applications such as MAT.
I have some code here that can programmatically 7 take a heap dump over JMX:
Link: JmxHeapDumper.java
The comments 6 in the source code contain 2 links to articles 5 that contained useful information about 4 how to take heap dumps. I don't know for 3 sure but if you are in luck, perhaps the 2 JMX approach would have some way of avoiding 1 the GC. Hope this helps !
I suggest a 3rd-party profiler such as YourKit, which 4 may allow you to take snapshots without 3 kicking off the GC first. Added bonus, you 2 can take a snapshot without the whole ctrl-break 1 shenanigans.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.