fwcd / vscode-kotlin

Kotlin code completion, debugging, linting and more for VSCode
MIT License
298 stars 41 forks source link

java.lang.OutOfMemoryError: Java heap space #120

Open canda opened 1 year ago

canda commented 1 year ago

Description

I'm not sure how to repro. I'm trying to use this extension in a big private repository. When I start vscode, the cpu (mac intel) goes brrrr, after a while, the kotlin output shows the error detailed bellow. The go to definition does command does not work (cmd+click triggers an infinite blue loading animation at the top of the editor, but nothing else happens).

Extension version

VSCode 1.76.2 fwcd.kotlin v0.2.26

Additional context

kotlin output

[Info  - 8:10:05 AM] async3    Updating symbol index...
[Info  - 8:10:05 AM] async3    Updated symbol index in 0 ms! (1305 symbol(s))
[Info  - 8:10:17 AM] async3    Updating symbol index...
[Info  - 8:10:17 AM] async3    Updated symbol index in 0 ms! (1315 symbol(s))
[Error - 8:12:56 AM] org.jetbrains.kotlin.util.KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration Reviews
File being compiled: (32,1) in //Users/user/projects/.../reviews.kt
The root cause java.lang.OutOfMemoryError was thrown at: unknown
[Error - 8:12:56 AM]    at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:43)
...
[Error - 8:12:56 AM]    at java.base/java.lang.Thread.run(Thread.java:832)
[Error - 8:12:56 AM] Caused by: java.lang.OutOfMemoryError: Java heap space
[Error - 8:14:49 AM] org.jetbrains.kotlin.util.KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration RefreshmentsOfferReviewGroup
[Error - 8:14:49 AM]    at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:43)
...
[Error - 8:14:49 AM]    at java.base/java.lang.Thread.run(Thread.java:832)
[Error - 8:14:49 AM] Caused by: java.lang.OutOfMemoryError: Java heap space
canda commented 1 year ago

Is there any way to assign more heap space to the java runtime?

themkat commented 1 year ago

@fwcd this is language server issue, not a vscode plugin issue, could we transfer it? Possibly also a duplicate of https://github.com/fwcd/kotlin-language-server/issues/441 .

You can change the java heap space with environment variables. The most common way is to use the java option -Xmx8g (which would make it 8GB). This can be done by setting JAVA_OPTS or similar environment variables variables. See our discussion in the language server repo for more details: https://github.com/fwcd/kotlin-language-server/issues/441

Some things to think about: