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

Set the vmArg HeapDumpOnOutOfMemoryError to be optional #1212

Closed
licam opened this issue Mar 21, 2024 · 16 comments
Closed

Set the vmArg HeapDumpOnOutOfMemoryError to be optional #1212

licam opened this issue Mar 21, 2024 · 16 comments
Assignees
Labels
for: vscode something that is specific for VSCode type: enhancement

Comments

@licam
Copy link

licam commented Mar 21, 2024

Expected Behavior

Do not write heap dump files in case the user doesn't wants it. The user can disable this by a setting.

Current Behavior

The extension adds '-XX:+HeapDumpOnOutOfMemoryError' automatically:
https://github.com/spring-projects/sts4/blob/main/vscode-extensions/vscode-spring-boot/lib/Main.ts#L43
On cases where our users get OOM, their file system is blowing up with the hprof files. Can this be disabled by a setting? It can be set to true by default, and when a user wish to not have this files he can choose to disable it.

Context
We will use -XX:HeapDumpPath to write the files to some temp folder. But we need to be able to not have it written at all, as was on older versions of this extension. As our IDE is on cloud with shared resources it's problematic once this huge files are generated and blows up the disk.

@martinlippert
Copy link
Member

Absolutely agree @licam , this default setting it still there from the early days and should be removed. In case of debugging OOM situations, users can add this back via the preferences.

@martinlippert
Copy link
Member

Beyond that: if you are encouraging OOM situations with the language server process (sounds like you do), it would be extremely interesting to share some details here (maybe even one of those generated heap dumps) to debug this situation and see why you are running into the OOM situation.

@licam
Copy link
Author

licam commented Mar 21, 2024

Thank you for the prompt response. We have a certain case where there's a huge Java project and the users gets OOM all the time from the extension. For our best understanding, that's because of the size of the project. Unfortunately we do not have the project either as it's a customer's project and they are not allowed to share. Regarding the heap dump, I'm verifying it.

@martinlippert
Copy link
Member

You could also add -Xmx2048m as a JVM arg to the preferences for the JVM that is used to run the language server in order to avoid the OOM situation as well. But nevertheless, it would be extremely interesting to analyze the OOM situation in more detail for us.

@licam
Copy link
Author

licam commented Mar 21, 2024

Thanks. We are aware of that, but as the resources are shared between the cloud users, increasing the heap size might have a negative effect on other users.

@martinlippert
Copy link
Member

Understand. One additional argument to dive deeper here and analyze the root cause of the OOM and fix that... :-)

@BoykoAlex
Copy link
Contributor

Fixed with 01a69ba

@martinlippert
Copy link
Member

@licam I still would love to get a few more details about this OOM and try to find the root cause for this. Can you provide insights into:

  • how large is the project? how many java source files (roughly)?
  • if you enable the log output of the Spring Boot language server to be written to a file (you can define a file in the preferences), could you paste the OOM stack trace that shows up there and maybe a few additional lines above that exception (or - if possible - the full log file)?

I would like to investigate this in more detail to see if we can avoid the OOM altogether and make the tooling work smoothly even if you have those large projects and limited memory settings for the tooling and the language server process.

Very much hope that you can share those details.

@licam
Copy link
Author

licam commented Mar 28, 2024

@martinlippert The project contains around 16K Java files.

Here's the stack trace:
pool-5-thread-1
at java.lang.OutOfMemoryError.()V (OutOfMemoryError.java:48)
at java.util.Arrays.copyOfRange([CII)[C (Arrays.java:3966)
[…]
at org.eclipse.jdt.core.dom.ASTParser.createASTs([Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;Lorg/eclipse/jdt/core/dom/FileASTRequestor;Lorg/eclipse/core/runtime/IProgressMonitor;)V (ASTParser.java:1049)
at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.scanFiles(Lorg/springframework/ide/vscode/commons/java/IJavaProject;[Ljava/lang/String;Ljava/util/List;Ljava/util/List;Ljava/util/function/BiConsumer;Lorg/springframework/ide/vscode/boot/java/utils/SpringIndexerJava$SCAN_PASS;)[Ljava/lang/String; (SpringIndexerJava.java:566)
at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.scanFiles(Lorg/springframework/ide/vscode/commons/java/IJavaProject;[Ljava/lang/String;Z)V (SpringIndexerJava.java:498)
at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.initializeProject(Lorg/springframework/ide/vscode/commons/java/IJavaProject;Z)V (SpringIndexerJava.java:153)
at org.springframework.ide.vscode.boot.app.SpringSymbolIndex$InitializeProject.run()V (SpringSymbolIndex.java:871)
at java.util.concurrent.CompletableFuture$AsyncRun.run()V (CompletableFuture.java:1804)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run()V (ThreadPoolExecutor.java:635)
at java.lang.Thread.run()V (Thread.java:833)

@martinlippert
Copy link
Member

@licam Thanks for the additional details, much appreciated. I might ask you to try a snapshot with this huge project to see if future changes make a reasonable difference, so stay tuned and be prepared... ;-)

Also, if you have tried different -Xmx settings, it would be interesting to hear how much memory would make the OOM error to not appear anymore.

@licam
Copy link
Author

licam commented Mar 28, 2024

I tried asking the customer which Xmx value is enough for his project but I don't have a reply yet.
I'll add here any more information once I'll have it.
Regarding the snapshot, it will be great. Thanks!

@martinlippert
Copy link
Member

I will continue the work on optimizing the memory consumption in #1219. Looks like the indexing mechanism (which parses the source files) is causing the memory spikes and therefore OOM errors when indexing projects with many source files.

@martinlippert
Copy link
Member

Some early results of the memory footprint improvements: #1219 (comment)

@licam
Copy link
Author

licam commented May 30, 2024

Hi @martinlippert, when will you release vscode-spring-boot 1.54.0 to open-vsx?

@martinlippert
Copy link
Member

Hi @martinlippert, when will you release vscode-spring-boot 1.54.0 to open-vsx?

Done, thanks for the reminder. Looks like something went wrong unnoticed during the automation here.

@licam
Copy link
Author

licam commented May 30, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: vscode something that is specific for VSCode type: enhancement
Projects
None yet
Development

No branches or pull requests

3 participants