Working with Snapshots
VisualVM enables you to take snapshots of application data and save the snapshots to your local system. Snapshots are a convenient way to capture data about an application because after a snapshot is saved it can be opened and viewed at any time. The target application does not need to be running to view the snapshot. Snapshots can also be sent and viewed by other people.
Snapshot Types
Snapshots are basically archives of data captured at a point in time that can then be opened in VisualVM. You can take and save the following types of snapshots:
Profiler Snapshots
Profiler snapshots capture profiling data at the moment the snapshot is taken. You can take a profiler snapshot at any time during a profiling session. When you take a profiler snapshot, a node representing the snapshot appears below the application node in the Applications window and a temporary snapshot file is written to your local system in the VisualVM userdir.
VisualVM can take the following types of profiler snapshots
- Memory Snapshot. A memory snapshot captures profiling data on allocated objects. You can take a memory snapshot when you are using the profiler to analyze memory usage.
- CPU Snapshot. A CPU snapshot captures data on the performance of the application. You can take a CPU snapshot when you are using the profiler to analyze application performance.
Screenshot of memory profiling snapshot
Screenshot of CPU profiling snapshot
If you want to view a profiler snapshot later, the snapshot must be explicitly saved to your local system, either as a profiler snapshot or archived in an application snapshot.
Taking Profiler Snapshots
You can take a profiler snapshot during a profiling session. When you take a memory or CPU snapshot, the snapshot opens in the application's tab in the main window.
To take a snapshot, do one of the following:
- Click the Take Snapshot of Collected Results button in the Profiler tab
- Right-click the application node and choose Profiler Snapshot.
The snapshot toolbar enables you to do the following:
- Save Snapshot to Custom File. Click to save snapshot as Snapshot file (.nps to your local system).
- Save Current View to Image. Click to save snapshot as an image (.png to your local system)
- Find in Results. Click to find a search term in the profiling results.
- Find Next Occurence. Click to find next occurrence of search term
- Find Previous Occurence. Click to find previous occurrence of search term
Application Snapshots
An application snapshot captures the collected heap dumps, thread dumps and profiler snapshots of an application at the moment the snapshot is taken. An application snapshot also captures general information about the Java Virtual Machine (JVM).
You take an application snapshot by right-clicking an application node in the Applications window and choosing Application Snapshot from the popup menu. Application snapshots are persisted between VisualVM sessions.
When you take an application snapshot:
- An application snapshot node appears under the Snapshots node in the Applications window
- Application data is saved in a folder in the the repository/snapshots folder in the VisualVM user dir
Application snapshots are listed under the Snapshots node in the Applications window. Expand the application snapshot node to view the contents of the snapshot.
After you take an application snapshot, you can view and modify the contents by expanding the application snapshot node in the Applications window. You can right-click an application snapshot node or any of the items listed under the application snapshot node to open the popup menu where you can choose to open, save, rename and delete the item. You can then save the application snapshot as a single application snapshot archive (.apps) to your local system.
The Overview tab of an application snapshot captures data about the JVM software.