Java has a built-in feature for dumping heap snapshots to files in HPROF binary format. You can analyze these snapshots using all of the powerful features that YourKit Java Profiler provides for its own memory snapshots.
HPROF snapshots can be created in the following ways:
Sun Java 6 has the
jmap utility that allows to connect to running Java process and dump Java heap:
jmap -dump:format=b,file=file_name.hprof <pid>
The benefit is that memory can be analyzed on demand with no additional configuration of JVM or Java application. You can dump memory of any running instance of JVM that supports this feature (see the list above).
Sun Java has the
jconsole utility that lets you to connect to a running Java 6 process
for monitoring and management:
Using jconsole, you can dump Java heap via HotSpotDiagnostic MBean
This approach has a lot of drawbacks and is not useful nowadays, but is mentioned here to show the complete picture.
HPROF snapshots (*.hprof) can be opened the same way as YourKit Java Profiler format snapshots (*.snapshot)
Some HPROF snapshots do not contain values of primitive types.
When such snapshots are opened in the profiler, values of
java.lang.String's will not be available.