JFR's memory leak profiler (underneath the event jdk.OldObjectSample) samples object allocations and wraps a sample in a weak handle.
ZGC only does weak reference processing in the old generation. Therefore, all objects that would usually die because we are sampling a lot of stuff that immediately becomes garbage will be artificially kept alive until an old-generation collection.
This incurs a significant performance hit by causing allocation stalls.
Attached is a reproducer, along with basic -Xlog:gc* log files, comparing runs when the JDK.OldObjectSample event is enabled vs disabled.
The easiest way to turn on / off the event (it is turned on by default) is to override event settings on the command line, like so:
-XX:StartFlightRecording:jdk.OldObjectSample#enabled=false
ZGC only does weak reference processing in the old generation. Therefore, all objects that would usually die because we are sampling a lot of stuff that immediately becomes garbage will be artificially kept alive until an old-generation collection.
This incurs a significant performance hit by causing allocation stalls.
Attached is a reproducer, along with basic -Xlog:gc* log files, comparing runs when the JDK.OldObjectSample event is enabled vs disabled.
The easiest way to turn on / off the event (it is turned on by default) is to override event settings on the command line, like so:
-XX:StartFlightRecording:jdk.OldObjectSample#enabled=false