- 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
HPROF (Heap Profiler) snapshots
HPROF memory snapshot, or heap dump, is a snapshot of Java heap memory at a specific point in time. It records all objects in the heap, as well as the references between them. Analyzing HPROF snapshot helps you understand what objects are consuming memory, the relationship between objects, and how the memory is utilized by the application.
Besides objects in the Java heap, HPROF snapshot can optionally contain information about thread stacks that were running at the moment the snapshot was taken. You can examine the list of threads and their stacks in the Threads tab.
Moreover, if an OutOfMemoryError
occurred in the program
during the invocation of a Java object constructor
<init>
,
YourKit Java Profiler will locate this thread and highlight it
with a special
icon.
- Pros and cons of HPROF snapshots
- When to use HPROF snapshots
- How to capture HPROF snapshot
- Analyzing HPROF snapshot
- Converting YourKit snapshot to HPROF
Pros and cons of HPROF snapshots
Fast and efficient: HPROF snapshots are recognized for their speed and efficiency. They are natively supported by HotSpot JVMs, eliminating the need for an external profiler agent.
Resource-friendly: When capturing snapshots, HPROF is designed to consume fewer system resources. It accomplishes this by leveraging internal JVM functions and structures to iterate over the heap. This approach minimizes the performance impact on the system, making it an attractive option for applications running in production environments.
Limited data: A notable limitation of HPROF snapshots is that they focus exclusively on JVM heap data. Specifically, HPROF snapshots lack CPU usage data and telemetry, which can be critical for thorough performance analysis.
When to use HPROF snapshots
- Use HPROF for memory profiling tasks, such as identifying memory leaks, when your focus is exclusively on memory analysis rather than CPU or thread profiling.
- For scenarios where the used heap size exceeds half of the available RAM size, it is advisable to use HPROF snapshots. This recommendation stems from HPROF's efficient heap iteration.
How to capture HPROF snapshot
HPROF snapshots can be captured through JVM arguments, programmatically, or using YourKit Java Profiler. HPROF provides a fast, low-resource way to capture heap dumps directly from the JVM, even if the profiling agent is not loaded.
Automatically on OutOfMemoryError
Learn more how to
capture HPROF snapshot right when your
Java application crashes due to an OutOfMemoryError
.
Capture HPROF snapshot from the profiler UI

Capture HPROF snapshot via profiler HTTP API
Profiler HTTP API has
captureHprofSnapshot
endpoint which captures HPROF snapshot.
Capture HPROF snapshot via jmap
utility
Java's jmap
utility can connect to a running
Java process and dump its Java heap:
jmap -dump:format=b,file=file_name.hprof <PID>
To learn the PID (process identifier) of running JVM,
you can use jps
or jconsole
JDK utilities.
Capture HPROF snapshot via jconsole
utility
Java utility jconsole
allows you to connect to a running Java process
for monitoring and management.
Using jconsole
, you can dump Java heap via
HotSpotDiagnostic
MBean:

Capture HPROF snapshot programmatically
You can also generate a heap dump programmatically
using the HotSpotDiagnosticMXBean
interface:
package com.yourkit;
import com.sun.management.HotSpotDiagnosticMXBean;
import javax.management.MBeanServer;
import java.io.IOException;
import java.lang.management.ManagementFactory;
public class HprofDumper {
public static void main(String[] args) throws IOException {
dumpHeap("sample.hprof", true);
}
public static void dumpHeap(String fileName, boolean live) throws IOException {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(
server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
bean.dumpHeap(fileName, live);
}
}
Analyzing HPROF snapshot
HPROF snapshots can be opened and analyzed the same way as YourKit format snapshots.
Converting YourKit snapshot to HPROF
If you want to analyze a YourKit snapshot using third-party tools that support HPROF format, you can convert the YourKit snapshot to HPROF. Here is an example of how you can do this using profiler command line:
Linux
<profiler directory>/bin/profiler.sh -snapshot2hprof <source>.snapshot <target>.hprof
macOS
<profiler directory>/Contents/Resources/bin/profiler.sh -snapshot2hprof <source>.snapshot <target>.hprof
Windows
<profiler directory>\bin\profiler.bat -snapshot2hprof <source>.snapshot <target>.hprof