- System requirements
- Profiler architecture
- Profiler installation
- Uninstall profiler
- Running the profiler
- Profiler activation
- Welcome screen
- Start profiling
- Profiling overhead
- Snapshots
- Solving performance problems
- CPU profiling
- Thread profiling
- Virtual threads support
- Object allocation profiling
- Memory profiling
- Monitor profiling
- Exception profiling
- Telemetry
- Probes: monitor events of various kinds
- Inspections: automatic recognition of typical problems
- Automatically trigger actions on event
- Automatic deobfuscation
- Summary
- Filters
- Profiler command line
- Export of profiling results to external formats
- Profiler Java API
- Profiler HTTP API
- Settings
- Troubleshooting and FAQ
Memory snapshot
Memory management is a critical component of modern software development, and this is particularly true in Java that is often used in large-scale, complex applications. In Java, memory snapshots offer a way to capture the state of all objects and classes at a specific point in time.
- What is a memory snapshot?
- Information contained in a memory snapshot
- Supported memory snapshot formats
- Comparing memory snapshots
What is a memory snapshot?
A memory snapshot is essentially a dump of all objects, classes, and their interrelationships in a running Java application. These dumps can then be analyzed to identify memory leaks, inspect the object hierarchy, or even understand the execution state at that time.
Information contained in a memory snapshot
1) Memory snapshot is a dump of all objects and classes
When you capture a memory snapshot, you are taking a 'photograph' of the Java heap memory. It records all the objects that have been instantiated, their states, and classes involved. This is incredibly useful for debugging as you can inspect this snapshot to understand exactly what was in memory at that point in time.
2) It contains graph of all objects
The memory snapshot includes a graph that represents how objects reference each other. This object graph provides a way to visualize the relationships between objects and can be essential for understanding how data flows through your application. For example, you can find out which objects are being held in memory due to references, thereby leading to potential memory leaks.
3) It can optionally contain values of primitive fields
While a basic snapshot will give you the object and class structures,
it can also be configured to include the values of primitive fields
(such as int
, boolean
, char
, etc.)
within those objects.
This means that you can inspect the actual data within the objects,
not just their structure.
By looking at the state of these primitive fields,
you may be able to identify inconsistencies or
anomalies that could be the root cause of bugs.
4) It can contain optional information about where objects were allocated
Another optional feature is allocation profiling. This provides information about where in the code each object was allocated. Knowing the allocation site can be extremely useful for debugging purposes, especially for finding memory leaks or understanding complex object lifecycles.
Supported memory snapshot formats
YourKit Java Profiler is a polyglot tool, which is able to load and analyze snapshots from many popular profiling utilities:
HPROF
HPROF (Heap Profiler) dumps,
the files with .hprof
extension, are memory
snapshots created by the JVM's built-in heap dumper.
PHD
IBM Portable Heap Dumps (PHD), the files with .phd
extension, are memory snapshots created by IBM Java.
YourKit
This is a native snapshot format of YourKit Java Profiler.
Snapshot files have .snapshot
extension.
YourKit format is optimized for fast and efficient reading.
Thanks to its container structure, various types of data can
be stored in the snapshot, including CPU profiling data,
performance telemetry, and so on.
Comparing memory snapshots
Lear more how to compare memory snapshots.