Saving Live Sessions To Disk


  Snapshots of live profiling sessions can be saved to disk by selecting Session->Save Snapshot from JProfiler's main menu or by clicking on the corresponding  tool bar entry in JProfiler's main tool bar.

A file chooser will be brought up where you can select the name and directory of the snapshot file to be written. The standard extension of JProfiler's snapshot files is *.jps. Once JProfiler has finished writing the snapshot to disk, a message box informs you that the snapshot was saved.

A bookmarks will be added when a snapshot is saved manually.

  Besides JProfiler snapshots, JProfiler can also open HPROF heap dump files as well as PHD files (portable heap dump files created by IBM JVMs). Right from the JProfiler GUI you can save HPROF snapshots with the Profiler->Save HPROF Snapshot. You will be asked to provide a file name for the HPROF snapshot. The snapshot file will be given an .hprof extension and will be saved on the computer where the profiled JVM is running. The path will be interpreted as relative to the current directory of the profiled JVM.

In situations where physical memory is sparse, saving an HPROF snapshot can be preferable compared to saving a full JProfiler snapshot. Also, there are alternative ways to save HPROF snapshots:

  • with -XX:+HeapDumpOnOutOfMemoryError
    The -XX:+HeapDumpOnOutOfMemoryError VM parameter is supported by Hotspot JVMs and is the basis of the "Out of memory exception" trigger type.
  • with jmap
    The jmap executable in the JDK can be used to extract an HPROF heap dump from a running JVM. It is partially supported by Sun 1.5 JVMs and supported by all Sun 1.6 JVMs.
  • with the command line utility jpdump provided by JProfiler
    JProfiler includes a command line tool that is more versatile than jmap. It lets you select a process, can connect to processes running as a service on Windows, has not problems with mixed 32-bin/64-bit JVMs and auto-numbers HPROF snapshot files. If you execute it with the -help option, you will get help on its usage:
      Usage: jpdump [options]
    
      jpdump saves an HPROF heap dump from a locally running JVM to a file.
      The HPROF file can then be opened in the JProfiler GUI.
    
      * if no argument is given, jpdump lists all locally running JVMs.
      * with the following arguments you can partially or completely supply all
        user input on the command line:
    
        -p  --pid=PID      The PID of the JVM whose heap should be dumped
                           With a specified PID, no further questions will by asked.
        -a  --all          Save all objects. If not specified, only live objects are
                           dumped
        -f  --file=PATH    Path to the dump file. If not specified, the dump file
                           <VM name>.hprof is written in the current directory.
                           If the file already exists, a number is appended.
        -h  --help         Show this help
    
      Note that the JVM has to be running as the same user as jpdump, otherwise
      JProfiler cannot connect to it.
      An exception are Windows services running under the local system account if you
      list them interactively with jpdump.
  • By clicking the [Heap Dump Only] button in the "Quick attach" tab of the start center. This has the same effect as the jpdump command line utility described above, just that you can select the JVM and the target file in the JProfiler GUI.
  You can also save snapshots with the offline profiling API or use a trigger and the "Save snapshot" and "Create a HPROF heapdump" actions to save snapshot in an exact way. This is also useful for offline profiling.
  Saved snapshots can be loaded
  • by selecting Session->Open Snapshot from JProfiler's main menu.
  • by selecting a file from the "Open snapshot" tab in JProfiler's start center.
The following restrictions apply when viewing snapshots:
  • JProfiler snapshots

    After a JProfiler snapshot has been loaded, the functionality of all views is identical to a live profiling session with the exception of the heap walker view: The heap walker overview will be shown if a heap snapshot was taken at the time of saving, otherwise the heap walker will be unavailable.

  • HPROF snapshots

    When an HPROF snapshot is loaded, only the heap walker is available. Also, the "Allocations" and "Time" views of the heap walker are not available.

  • PHD snapshots

    When a PHD snapshot is loaded, only the heap walker is available. Also, the "Allocations" and "Time" views of the heap walker are not available. PHD files do not contain garbage collector roots, so JProfiler simulates classes as roots. Finding class loader memory memory leaks may be difficult with a PHD file.

The status bar indicates that a snapshot is being viewed by displaying the message  Snapshot in its rightmost compartment.