Skip to content

Conversation

fandreuz
Copy link
Contributor

@fandreuz fandreuz commented Oct 10, 2025

I propose to amend nmethod::is_cold to let GC collect not-entrant native nmethod instances.

Passes tier1 and tier2 (fastdebug).


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8369219: JNI::RegisterNatives causes a memory leak in CodeCache (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27742/head:pull/27742
$ git checkout pull/27742

Update a local copy of the PR:
$ git checkout pull/27742
$ git pull https://git.openjdk.org/jdk.git pull/27742/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27742

View PR using the GUI difftool:
$ git pr show -t 27742

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27742.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 10, 2025

👋 Welcome back fandreuzzi! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 10, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Oct 10, 2025

@fandreuz The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@fandreuz fandreuz changed the title 8369219: Let GC reclaim cold native wrappers 8369219: JNI::RegisterNatives can cause a memory leak in CodeCache Oct 10, 2025
@fandreuz fandreuz marked this pull request as ready for review October 11, 2025 14:51
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 11, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 11, 2025

Webrevs

@dholmes-ora
Copy link
Member

/label add hotspot-compiler

@openjdk
Copy link

openjdk bot commented Oct 13, 2025

@dholmes-ora
The hotspot-compiler label was successfully added.

@fandreuz fandreuz changed the title 8369219: JNI::RegisterNatives can cause a memory leak in CodeCache 8369219: JNI::RegisterNatives causes a memory leak in CodeCache Oct 13, 2025
// nmethods that don't seem to be all that relevant any longer.
bool nmethod::is_cold() {
if (!MethodFlushing || is_native_method() || is_not_installed()) {
if (!MethodFlushing || (is_native_method() && is_in_use()) || is_not_installed()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess we need to decide what to do about native wrappers that are still "in use", but are "cold" because they haven't been called in a while. The above change would keep them around forever. We could instead allow them to be cleaned up like regular nmethods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants