GeezerVison is showing github.com — Fix code cache memory leak in lock profiling while looping by fandreuz · Pull Request #1575 · async-profiler/async-profiler
Conversation
fandreuz
commented
Nov 3, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Description
We decided to avoid resetting Unsafe::park in LockTracer::stop to avoid incurring in the problem reported in #1453. We can accept leaving around the hook since the alternative is a memory leak.
Related issues
This is a workaround for #1453 and JDK-8369219.
Motivation and context
The fix was merged in OpenJDK, but it will take some time to have it backported.
How has this been tested?
The reproducer provided by the user is not reproducing the problem after the change:
$ ./script/run.sh --agent async-profiler --loop 1s
[monitor] Unsafe.park codelist occurrences: 0 | codecache: no-heap-lines
[monitor] Unsafe.park codelist occurrences: 1 | codecache: no-heap-lines
[monitor] Unsafe.park codelist occurrences: 1 | codecache: no-heap-lines
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
fandreuz
changed the title
Lightweight continuous profiling for Java lock profiling
Lightweight continuous profiling for Java locks
Nov 3, 2025
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
fandreuz
changed the title
Lightweight continuous profiling for Java locks
Fix code cache memory leak in lock profiling while looping
Nov 6, 2025
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
|
jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL);
|
|
|
|
|
|
// Reset Unsafe.park() trap
|
|
|
setUnsafeParkEntry(env, _orig_unsafe_park);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is not longer reset, how about moving the setUnsafeParkEntry(env, UnsafeParkHook); to be done inside the if (!_initialized) check as it's only needed on the first call to start
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense, my only argument against this change would be that the goal we discussed for this PR is to fix the memory leak. Reducing the overhead of continuous profiling is out of scope.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here with a link to the bug why we don't reset the hook?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
apangin
apangin left review comments
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|