Repository navigation
High CPU usage and memory consumption even if doing nothing #3387
Copy link
Copy link
Closed
eclipse-jdtls/eclipse.jdt.ls
#3196Description
originally reported by @wkia at microsoft/vscode-java-debug#1408
I'm working with OpenJDK 11/17/21/... source code on Windows 11, WSL, and Linux.
"Debugger for Java" is v0.55.0. This issue is related to #1330 (comment), but I tried to reproduce it from scratch.
The example from WSL, just open VSCode with my workspace and see - it consumes CPU and memory for a long time:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 6174 user 20 0 37.9g 14.2g 3.5m S 832.9 91.0 11:57.35 /home/user/.vscode-server/extensions/redhat.java-1.24.0-linux-x64/jre/17.0.8.1-linux-x86_64/bin/java --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.ecli+And then, when memory is about to out, it looks like it drops the process and starts again - with a small amount of memory and high CPU usage, increasing memory consumption every sec.
Steps To Reproduce (on Win11/WSL)
- Install VSCode on Win11, and install "Remote Development" extension pack
- Open WSL terminal, and run the following commands:
git clone https://github.com/openjdk/jdk.git openjdkcp MyApp.java openjdk(see below for MyApp.java source code)cd openjdkcode . &- In VSCode, Install "Debugger for Java", "Language support for Java" to remote WSL.
- In VSCode, open
~/openjdk/MyApp.javafile in editor.- In WSL terminal, run
top -cand see.vscode-server/extensions/redhat.java-1.24.0-linux-x64/jre/17.0.8.1-linux-x86_64/bin/javaconsuming CPU and memory. (in my case it consumes all CPU cores)- Wait patiently, and still click 'Increase memory' and 'Reload window' in VSCode if it asks, continue seeing RedHat java process in
top -clist consuming CPU and RAM.- You could stop here, but you also can try to reach the maximum memory amount in WSL allocated for VSCode by clicking 'Increase memory'/'Reload window', and possibly you will see behaviour described in Cannot debug JDK17 itself with "Debugger for Java" v0.49.1 #1330 (comment)
- (Optional) You could also try to close and open VSCode again, instead of 'Reload'ing window. It seems it helps to reproduce it faster.
MyApp.java
public class MyApp { public static void main(String[] args) { System.out.println("Hello world!"); System.out.println("Sleeping..."); Thread.sleep(20000); System.out.println("Finished"); } }
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
wkia commentedon Nov 10, 2023
I tried to dump the "redhat.java" process consumed 14GB RAM, and open the dump with visualvm. See screentshots here microsoft/vscode-java-debug#1330 (comment)
RoanHeNaN commentedon Dec 4, 2023
Meet same problem
johnmccutchan commentedon Dec 6, 2023
This is extremely annoying and happens daily for me.
tonyganchev commentedon Dec 14, 2023
Similar problems. on leaving my WSL dormant for the night I find it in the morning with 100% memory usage (24 GiB) and 40+ RedHat java agents running.
archenroot commentedon Dec 15, 2023
I disabled and reenabled the extension and it used initially high-cpu, but after few minutes it went down.
witlingw commentedon Jan 25, 2024
Same here, and we are using this extension at work and several of my colleagues are also blocked by this daily.
wkia commentedon Feb 26, 2024
I'm still able to reproduce the issue with ".vscode-server/extensions/redhat.java-1.28.1-linux-x64/jre/17.0.10-linux-x86_64" on JDK11 sources:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND5310 user 20 0 22.3g 14.6g 12.0m S 1390 93.4 28:44.33 /home/user/.vscode-server/extensions/redhat.java-1.28.1-linux-x64/jre/17.0.10-linux-x86_64/bin/jav+However I noticed that now the issue occurs when I put my test into the root folder of downloaded JDK sources:
$ git clone https://github.com/openjdk/jdk11u-dev.git$ cd jdk11u-dev$ cp test/hotspot/jtreg/compiler/loopopts/TestLoopUnswitchingLostCastDependency.java .$ code . &wkia commentedon Mar 5, 2024
The issue still occurs with JDK17 sources.
wkia commentedon May 9, 2024
I'm still facing the issue with
redhat.java-1.30.0on VSCode 1.89wkia commentedon Jun 3, 2024
Still there with VSCode 1.89.1 and redhat.java-1.31.0-linux-x64 on JDK17 sources.
maphdze commentedon Jun 13, 2024
Still here without Java extensions. Only writing latex with two vscode window open then the cpu will go to 60%-80%.
johnmccutchan commentedon Jun 14, 2024
This extension appears to be abandoned. I've deleted it and use Android Studio for working on Java code.
snjeza commentedon Jun 16, 2024
I can reproduce the issue when setting
The imported projects contain
javax.annotation.Nonnull, but don't containjavax.annotation.Nullable.JDT null analysis requires both of the classes to be included in the projects. Otherwise, it will throw an AIOOB exception and rebuild the workspace.
Java LS enables null analysis even when any of these classes is present. I'm preparing a patch.
@wkia @maphdze @johnmccutchan @witlingw @archenroot @tonyganchev @zhiqiang-hhhh could you try to set
Please check also <openjdk|jdk11u-dev|your_project_root>/.vscode/settings.json
7 remaining items
wkia commentedon Jul 5, 2024
Using version 1.32 now, I uninstalled the extensions, and install it again, the issue seems still there for me.
Also tried this setting in my workspace:
"java.compile.nullAnalysis.mode": "disabled"it doesn't help.
Still consumes a lot of memory (growing up to OOM error), and CPU ~1400%.
Tested with jdk22 sources.
snjeza commentedon Jul 5, 2024
@wkia I can't reproduce the issue.
"java.compile.nullAnalysis.mode": "disabled"isn't necessary anymore.Could you, please, try the following:
wkia commentedon Jul 5, 2024
I've cleaned workspace directory in both Windows and WSL. Removed ".vscode*" folders from $HOME and from the project directory.
The issue still occurs. Logs attached,
vscode.log
@snjeza Did you try to reproduce with the steps I provided at the very beginning?
See the description of the issue above, step 8: "In VSCode, open ~/openjdk/MyApp.java file in editor."
The issue starts occuring on the step 8, and it is continuing until I delete MyApp.java, and reload VSCode window.
You can even skip installing "Debugger for Java", install only "Language support for Java".
In my logs, I created a new file in VSCode (Ctrl+N), copy-n-pasted content of MyApp there, and saved as "openjdk/MyApp.java".
snjeza commentedon Jul 5, 2024
Yes, I did but still can't reproduce the issue.
Could you try to add
Could you reproduce the issue outside of WSL?
wkia commentedon Jul 8, 2024
Yes, I'm able to reproduce it on Windows 11:
All of the tries above ended up with OOM error:
Every time the issue occured I clicked "Increase..." again and again, so now my current workspace settings is:
wkia commentedon Jul 8, 2024
For the following settings, the try ended up with OOM error on Windows 11:
The logs:
vscode-win.log
As it is seen from logs, the reproducer took ~20 mins.
It consumed 60-80% of my i7-12700H.
No other extesions are installed, but "Language Support for Java(TM)" by Red Hat.
snjeza commentedon Jul 12, 2024
@wkia Could you attach your settings.json?
wkia commentedon Jul 13, 2024
@snjeza
User settings:
settings.json
Workspace setting:
settings.json
snjeza commentedon Jul 13, 2024
@wkia Could you try the following:
"java.import.maven.enabled": true,snjeza commentedon Jul 13, 2024
@wkia You can also try to add
and Clean the workspace directory
wkia commentedon Jul 15, 2024
@snjeza Here are the results:
"java.import.maven.enabled": true- issue is NOT reproducible"java.import.maven.enabled": false+"java.project.sourcePaths"- issue is NOT reproducibleDouble checked without the changes above - issue is still reproducible.
Also, just in case checked,
"java.import.maven.enabled": falseonly, without adding"java.project.sourcePaths"- issue is reproducible.Cleaned workspace before each test case.
Tested on Windows 11, not WSL.
wkia commentedon Jul 16, 2024
@snjeza I'm happy to use the setting above as a workaround, however I don't like an idea to tune settings for all new workspaces I create. Is it going to be fixed somehow in further releases?
wkia commentedon Jul 22, 2024
@snjeza
The issue is still reproducible on Windows 11 with "test" folder rather than "src":
And it is still reproducible on WSL even with:
snjeza commentedon Jul 23, 2024
@wkia Could you try the following:
See IDE support in the JDK
wkia commentedon Aug 12, 2024
@snjeza It seems helping. Thanks!