GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@fandreuz fandreuz commented Nov 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

All reactions
@fandreuz fandreuz changed the title Lightweight continuous profiling for Java lock profiling Lightweight continuous profiling for Java locks Nov 3, 2025
Baraa-Hasheesh
Baraa-Hasheesh reviewed Nov 3, 2025
View reviewed changes
Comment thread src/profiler.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

apangin
apangin reviewed Nov 3, 2025
View reviewed changes
Comment thread src/lockTracer.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/profiler.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Baraa-Hasheesh
Baraa-Hasheesh reviewed Nov 3, 2025
View reviewed changes
Comment thread src/lockTracer.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/lockTracer.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/lockTracer.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Baraa-Hasheesh
Baraa-Hasheesh reviewed Nov 3, 2025
View reviewed changes
Comment thread src/lockTracer.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

apangin
apangin reviewed Nov 3, 2025
View reviewed changes
Comment thread src/lockTracer.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/lockTracer.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/lockTracer.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz
fandreuz force-pushed the loop-nostop-lock branch 2 times, most recently from 17efbea to 772c538 Compare November 6, 2025 01:28
Baraa-Hasheesh
Baraa-Hasheesh reviewed Nov 6, 2025
View reviewed changes
Comment thread test/test/lock/LockTests.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test/lock/LockTests.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test/lock/LockTests.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/lockTracer.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz fandreuz changed the title Lightweight continuous profiling for Java locks Fix code cache memory leak in lock profiling while looping Nov 6, 2025
apangin
apangin reviewed Nov 6, 2025
View reviewed changes
Comment thread src/profiler.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/lockTracer.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz
fandreuz marked this pull request as draft November 20, 2025 19:29
@fandreuz
don't reset entry
dd3a3b8
@fandreuz
fandreuz force-pushed the loop-nostop-lock branch from 772c538 to dd3a3b8 Compare December 8, 2025 14:06
@fandreuz
fandreuz marked this pull request as ready for review December 8, 2025 14:10
Baraa-Hasheesh
Baraa-Hasheesh reviewed Dec 8, 2025
View reviewed changes
Comment thread src/lockTracer.cpp
jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL);

// Reset Unsafe.park() trap
setUnsafeParkEntry(env, _orig_unsafe_park);

@Baraa-Hasheesh Baraa-Hasheesh Dec 8, 2025

Copy link
Copy Markdown
Contributor

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.

All reactions

@fandreuz fandreuz Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

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.

All reactions

@apangin apangin Dec 8, 2025

Copy link
Copy Markdown
Collaborator

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.

All reactions

@fandreuz fandreuz Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

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.

Sure: 2136dff

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@fandreuz
comment
2136dff
@apangin
apangin merged commit 3a493be into async-profiler:master Dec 8, 2025
@Baraa-Hasheesh Baraa-Hasheesh mentioned this pull request Dec 9, 2025
Codecache memory leak in lock profiling on stop/start #1453
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@apangin apangin apangin left review comments
+1 more reviewer
@Baraa-Hasheesh Baraa-Hasheesh Baraa-Hasheesh left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@fandreuz @apangin @Baraa-Hasheesh
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.