- 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
- JFR (Java Flight Recorder)
- 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
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
- It provides the maximum level of details including thread information, full stack traces of object creation, and object size.
- You can profile object allocations on older Java versions that do not support heap sampling, such as Java 8.
- 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
- 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.
- 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.
- 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.
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.