- 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
Classic allocation profiling
How classic allocation profiling works
For applications running on Java 8 - Java 10, the profiler uses
bytecode instrumentation.
It detects and modifies new
instructions in the bytecode,
allowing tracking of all Java object creations.
For Java 11 and later, YourKit Java Profiler uses a different, more efficient approach: heap sampling with the smallest possible sampling interval.
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 has a 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 provides options that allow efficient allocation profiling while maintaining moderate performance overhead:
- The first option specifies the minimum object size for which an allocation stack trace is always recorded. For example, if the minimum size is set to 4KiB, stack traces will be recorded for the creation of all objects of 4KiB or larger. This ensures that all significant allocations are captured.
- But what if the program creates many small objects? For this, there is a second option: "record every N-th object smaller than the minimum size". This option allows collecting statistical data on the creation of small objects.
As a result, with moderate performance impact, we can obtain complete information about all large object allocations and statistical data on small object allocations.