Fully featured low overhead profiler for Java EE and Java SE platforms.
Easy-to-use performance and memory .NET profiler for Windows, Linux and macOS.
Secure and easy profiling in cloud, containers and clustered environments.
Performance monitoring and profiling of Jenkins, Bamboo, TeamCity, Gradle, Maven, Ant and JUnit.

Heap sampling

How heap sampling works

Heap sampling, introduced in Java 11 (JEP 331), is a JVM feature that enables low-overhead, probabilistic tracing of object allocations. It periodically samples allocations on the Java heap, capturing stack traces and metadata (such as object size and type) for a subset of allocated objects. This is achieved using the JVM's memory allocation mechanisms, with a configurable sampling interval that determines how often allocations are recorded.

Advantages

  1. It provides the same level of detail as classic method (including thread information, full stack traces of object creation, and object size) but with lower overhead.
  2. Heap sampling is less invasive because it does not require bytecode instrumentation. It does not increase bytecode size or slow down class loading.
  3. This is especially useful in attach mode, as it prevents the pause that occurs on the first attempt to start object allocation profiling due to instrumenting classes loaded before the agent attaches.

Limitations

Because heap sampling only collects data on a fraction of the total allocations — rather than capturing every object allocation — it may miss objects. This can lead to partial or skewed insights into which code paths are responsible for the bulk of allocations.

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.