vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Latest vscode extension causes massive spike in CPU usage even when idle

Open u84six opened this issue 2 years ago • 23 comments

[provide a description of the issue]

Environment
  • Operating System: Windows 10
  • JDK version: 11.0.12
  • Visual Studio Code version: 1.72.1
  • Java extension version: latest as of (Oct 11/22)
Steps To Reproduce
  1. After the extension was updated, my fans on my laptop went into high gear.
  2. Opened performance monitor and noticed that java updater was pinning the CPU
  3. I then opened vscode and looked at all the extensions that I have enabled and latest updated.
  4. Noticed that Java Redhat extension has been recently updated.
  5. Disabled the extension and CPU went back to normal and fans stopped spinning.

There's really nothing else to say. The extension updated and caused massive CPU spikes when vscode is running. Disabling the extension fixed the problem.

u84six avatar Oct 11 '22 23:10 u84six

Are you able to share the sample project that was used when this happened ? Was it a Maven, Gradle, or un-managed project.

rgrunber avatar Oct 12 '22 13:10 rgrunber

I had no project. It was simply an upgrade of the extension that caused this. Disabling the extension fixed the issue. But what I did notice was that the java updater was running in the background for some reason. I don't have any auto-update enabled or anything, so I don't know why this was running. I killed the java update service and the problem persisted, so kept trying to figure out what changed in my system. Then I quit vscode and the cpu spike went down, so I opened up vscode again and started looking at the dates of the last updates of my extensions and noticed the java redhat extension was updated on Oct 11, so I disabled it, and then the problem went away. On Wednesday, October 12, 2022 at 09:24:34 AM EDT, Roland Grunberg @.***> wrote:

Are you able to share the sample project that was used when this happened ? Was it a Maven, Gradle, or un-managed project.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

u84six avatar Oct 12 '22 13:10 u84six

@u84six Could you try to add

"java.jdt.ls.vmargs": "-DwatchParentProcess=false -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx3G -Xms100m -Xlog:disable"

to your settings.json?

snjeza avatar Oct 12 '22 16:10 snjeza

I can't reproduce the issue? @u84six Could you show your Extension view? ext

snjeza avatar Oct 12 '22 23:10 snjeza

I'm not sure how a screenshot of my extension view is going to help, but here it is:

On Wednesday, October 12, 2022 at 07:56:28 PM EDT, Snjeza ***@***.***> wrote:  

I can't reproduce the issue? @u84six Could you show your Extension view?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

u84six avatar Oct 13 '22 18:10 u84six

I'm not sure how a screenshot of my extension view is going to help, but here it is:

I suppose VS Code hasn't finished updating Java LS.

I had no project.

In this case, VS Code doesn't start Java LS, but will try to update it.

snjeza avatar Oct 13 '22 18:10 snjeza

I didn't know that Java runtime was embedded in vscode extension. So that explains the fans kicking in like crazy. I'm surprised that there's no indicator of that happening. The extension itself didn't show anything about an update that seemed to go on for a long time. I mean, my fans were at full force for a couple hours until I killed the process and disabled the extension. On Thursday, October 13, 2022 at 02:47:40 PM EDT, Snjeza @.***> wrote:

I'm not sure how a screenshot of my extension view is going to help, but here it is:

I suppose VS Code hasn't finished updating Java LS.

I had no project.

In this case, VS Code doesn't start Java LS, but will try to update it.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

u84six avatar Oct 13 '22 20:10 u84six

@u84six You can add

"update.enableWindowsBackgroundUpdates": false,

to your setting.json. It will disable background updates.

snjeza avatar Oct 13 '22 21:10 snjeza

How long is this going to last? Now that we kind of know what this is, I decided to let it do its thing. But it has been hours, and my laptop is getting really hot, fans keep spinning, and in Task Manager, I see "OpenJDK Platform binary" pinning the CPU because of its network activity. Do you know why OpenJDK is updating? I didn't know that an extension could actually trigger a Java update. I installed OpenJDK manually and not because of the vscode Java extension. On Thursday, October 13, 2022 at 05:08:03 PM EDT, Snjeza @.***> wrote:

@u84six You can add "update.enableWindowsBackgroundUpdates": false,

to your setting.json. It will disable background updates.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

u84six avatar Oct 14 '22 19:10 u84six

I think I have no choice other than disabling the Java extension. It's just taking too long. I don't know what it's doing, but it just continues to cause network activity (probably doing some type of update but I don't even know if it's working behind company firewall) which pins the CPU. It's practically melting my keyboard. I can't keep my hands on my keyboard for too long because it gets so hot! :) On Thursday, October 13, 2022 at 05:08:03 PM EDT, Snjeza @.***> wrote:

@u84six You can add "update.enableWindowsBackgroundUpdates": false,

to your setting.json. It will disable background updates.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

u84six avatar Oct 14 '22 19:10 u84six

For the "OpenJDK Platform binary" processes in your task manager, is it possible to look at their properties/details or even the "command line" tab and tell us what arguments are being passed to this Java process ? It may give us a better idea of whether these are processes started by vscode-java or something else.

rgrunber avatar Oct 14 '22 20:10 rgrunber

I will get you this info soon. For now, I need to disable it so I can get some work done. But I do know that the "OpenJDK Platform binary" process doesn't start unless I enable the extension. If I disable the Java Redhat extension, the process ends and is removed from the task manager. On Friday, October 14, 2022 at 04:03:22 PM EDT, Roland Grunberg @.***> wrote:

For the "OpenJDK Platform binary" processes in your task manager, is it possible to look at their properties/details or even the "command line" tab and tell us what arguments are being passed to this Java process ? It may give us a better idea of whether these are processes started by vscode-java or something else.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

u84six avatar Oct 14 '22 20:10 u84six

How long is this going to last?

It depends on your Internet connection. It lasts less than 1 minute on my machine (4-5mb/sec).

snjeza avatar Oct 14 '22 20:10 snjeza

I have started facing similar issue very recently, will check if disabling the extension helps in my case.

deepesh1511 avatar Jan 15 '23 08:01 deepesh1511

Hi, guys. I have exactly the same issue!!!!!, which drives me mad. But I am not using the java extension. Usually I just write latex with vscode and the OpenJDK begins to occupy my CPU to 100%. I still don't have clear clues on it. If you know how to solve it, please Email me ([email protected])! Thanks !!!!!

rainkings avatar Feb 22 '23 13:02 rainkings

Hi, guys. I have exactly the same issue!!!!!, which drives me mad. But I am not using the java extension. Usually I just write latex with vscode and the OpenJDK begins to occupy my CPU to 100%. I still don't have clear clues on it. If you know how to solve it, please Email me ([email protected])! Thanks !!!!!

I guess I find the reason. The extension Ltex, which help you do gammer/spell check that activate java.exe. By enabling it, java.exe is no longer awakened when writng latex. Apparently there is some bugs in Ltex. ....

rainkings avatar Feb 22 '23 13:02 rainkings

I am see this same issue, where redhat.java extension is taking up all the CPU (4 out 8 cores 100%).

Though this happens only when I open a specific file which is like a large Base class. On CMD + hovering on any variable within that file, vscode just shows loading....

Issue doesnt go away even if I close that file. I have to manually kill the extension process and it comes up back normal.

If you can let me know what else to check for diagnostics, I can do that and provide more info.

kanatti avatar Feb 04 '24 00:02 kanatti

@kanatti Could you attach a project example?

snjeza avatar Feb 04 '24 03:02 snjeza

Sorry. I don't have any other examples than the actual project, which is private code.

I also noticed that if I disable lombok there is no issue ("java.jdt.ls.lombokSupport.enabled": false)

kanatti avatar Feb 04 '24 06:02 kanatti

Sorry. I don't have any other examples than the actual project, which is private code.

I also noticed that if I disable lombok there is no issue ("java.jdt.ls.lombokSupport.enabled": false)

This was helpful, and fixed it for me. I wanted to add, though, that when I re-enabled lombok support, the problem didn't come back. So, even though I cleaned many times, it seems maybe something wasn't getting cleaned up. Needless to say, this is a different problem.

kropptrevor avatar May 31 '24 15:05 kropptrevor

There were some recent improvements to project import ( https://github.com/redhat-developer/vscode-java/issues/3637 ) so it could have been that if it was very recent.

rgrunber avatar May 31 '24 19:05 rgrunber

There were some recent improvements to project import ( #3637 ) so it could have been that if it was very recent.

Just to be clear, this has been happening for months. The VSCode process manager showed 0 CPU usage for everything under the extension host, but the extension host itself was sitting at 12 (1 core worth). I noticed the problem actually came back, but then I fiddled with the configuration again and that fixed it again. It's not clear that it's even caused by this extension, but I've only ever seen it with this extension enabled.

If you can provide some guidance on what other debug information we can collect, I can provide that next time it happens.

kropptrevor avatar Jun 03 '24 16:06 kropptrevor

Would someone be able to check if the issue still occurs with the latest pre-release of vscode-java (v1.32.2024062508) ? Just last week, we fixed a serious issue relating to null analysis that would have caused this similar behaviour (CPU spike when idle), https://github.com/redhat-developer/vscode-java/issues/3387 .

What's interesting, is this issue was originally reported in October 2022, and null analysis was first introduced at the end of September 2022.

rgrunber avatar Jun 26 '24 15:06 rgrunber