Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak at com.sun.tools.javac.util.SharedNameTable$NameImpl #897

Closed
clebertsuconic opened this issue Oct 23, 2023 · 9 comments
Closed

Comments

@clebertsuconic
Copy link

I found a leak with com.sun.tools.javac.util.SharedNameTable$NameImpl

I have been building this with artemis build. But I suspect this is not related to anything on my project. But I will list it here in case it's something hitting only my project:

to reproduce this:

find the mvnd daemon:

jps -v | grep mvnd

start a check-leak capturing: (https://github.com/check-leak/check-leak)

java -jar check-leak-0.12-SNAPSHOT.jar remote --report out-report --sleep 1000 --pid <the-pid>

(or if you don't like the fancy graphs... just monitor the number of instances through memory histograms.. which is pretty much what I'm doing on check-leak.. I'm just generating the fancy reports).

start the artemis build:

git clone https://github.com/apache/activemq-artemis.git
mvnd clean install -DskipTests=true

(you might want to do that once before starting the capturing of the histograms as the firs build will download a bunch of stuff from maven repo)

open ./out-report/index.html

Sort it by number of increases...

you will find the com.sun.tools.javac.util.SharedNameTable$NameImpl on the list of growing objects.

you will see that number of objects will keep growing forever.. if you build 10 times.. you get 10X the number of objects... for my build it's adding about 10K instances on every run.

@clebertsuconic
Copy link
Author

image

@clebertsuconic
Copy link
Author

first build 10K, second build 20K... this build.. 30k ^^^

@clebertsuconic
Copy link
Author

and just to give it a context on the version being used:


lebertsuconic@MacBook-Pro out % mvnd --version
Apache Maven Daemon (mvnd) 1.0-m7 darwin-amd64 native client (b2ef5d81997adbcdb72dc8c5603722538fa641fe)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jansi.osx.OsXNativePty
Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)
Maven home: /usr/local/Cellar/mvnd/1.0-m7-m39/libexec/mvn
Java version: 11.0.8, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

@cstamas
Copy link
Member

cstamas commented Oct 23, 2023

There is a SO article about this, it seems is not a leak per se but a "feature" of javac:
https://stackoverflow.com/questions/14617340/memory-leak-when-using-jdk-compiler-at-runtime

The article mentions undocumented javac flag that should disable this leak, the -XDuseUnsharedTable.

We need some proof that this javac flag works or not.
And IMHO solution to this issue would be to make mvnd augment (auto-add) this m-compiler-p/compilerArg configuration, if it solves the issue/leak.

@rmannibucau
Copy link
Contributor

Hi, it can be worth setting <fork>true</fork> in maven-compiler-plugin.

@clebertsuconic
Copy link
Author

@rmannibucau I tried setting fork=true , and It didn't seem to have an effect on that object. I gained 10 seconds (apparently) on my build.

@rmannibucau
Copy link
Contributor

While ant is calling javac it will cache ~32k Name instances so maybe bypassing this module would help

gnodet added a commit to gnodet/plexus-compiler that referenced this issue Oct 23, 2023
@clebertsuconic
Copy link
Author

I've tried it with the plexus update, by updating my maven compiler to a snapshot and that fixed the issue:
image

@gnodet
Copy link
Contributor

gnodet commented Oct 25, 2023

Closing as won't fix as this is not really a mvnd bug. Thx @clebertsuconic

@gnodet gnodet closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
gnodet added a commit to gnodet/plexus-compiler that referenced this issue Oct 26, 2023
gnodet added a commit to codehaus-plexus/plexus-compiler that referenced this issue Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants