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.

Allocation profiling with bytecode instrumentation

How it works

The profiler locates and modifies new instructions in the bytecode, injecting hooks at the points where objects are created. This process is called bytecode instrumentation.

Advantages

  1. It provides the maximum level of details including thread information, full stack traces of object creation, and object size.
  2. You can profile object allocations on older Java versions that do not support heap sampling, such as Java 8.
  3. In this mode, the creation of all objects can be tracked without exception, which is not possible with heap sampling due to its probabilistic nature.

Disadvantages

  1. Instrumentation introduces slightly higher overhead than heap sampling. Even when the allocation profiling is off, there is a small overhead from calling profiler support code.
  2. Instrumentation increases bytecode size and slows down class loading. In some cases, such as very long Java methods, instrumentation may not be possible if the method's bytecode exceeds the size limit.
  3. In attach mode, a pause occurs on the first attempt to start object allocation profiling because classes loaded before the agent attaches must be instrumented.

Performance overhead

Profiler overhead directly depends on the number of objects for which the profiler records a stack trace. The fewer stack traces the profiler records, the lower the overhead.

YourKit Java Profiler allows you to control overhead using the sampling interval parameter. For each Java thread, the profiler maintains a counter that tracks the number of bytes allocated by that thread. When the counter exceeds the sampling interval during object creation, the profiler records an allocation sample.

Allocation profiling settings

The larger the sampling interval, the fewer samples are recorded and the lower the overhead. Conversely, the smaller the sampling interval, the higher the overhead. If the interval is set to 1, the profiler records allocation data for every object.

YourKit uses cookies and other 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 YourKit privacy policy.