redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 442 forks source link

Repeated out of memory error (Extension: Language Support for Java - Red Hat) #2232

Open jkpubsrc opened 2 years ago

jkpubsrc commented 2 years ago

Extension: Language Support for Java (Red Hat)

OS: Ubuntu Linux


The extension tells me again that it runs out of memory. This is quite strange as I am developing a very small Java Module here and it already has increased the memory limit. It had been increased to 2G and now it has been increased to 4G by some kind of logic trying to compensate.

There seems to be a fundamental flaw in the Language Server, if 4 GByte of memory is required for something little as developing a small Java package.

Bug No. 1: The memory issue (see above).

Bug No. 2: To have to restart the whole VSCode IDE in order to compensate for this.

snjeza commented 2 years ago

@jkpubsrc Could you, please, attach a sample project and show your java.jdt.ls.vmargs property?

jkpubsrc commented 2 years ago

Update: My system has a total of 32 GByte memory and I terminated almost all processes, and the memory has been increased to 16 GB for the language server. Now I turned it back down to 4G as increasing it doesn't seem to help. My settings.json now is (again):

{
    "java.configuration.updateBuildConfiguration": "automatic",
    "java.dependency.packagePresentation": "hierarchical",
    "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m"
}

Right now I can't attach a sample project as this is still under development. It will be released as open source in a week or two.

I've dealt with projects much larger than this in the last month, even on systems with half the memory. Strangely there was no problem with those projects.

Can't I enable some debugging switch and get some informative error message from the language server? As this system here has 32G of memory my rough guess is that the real cause of the error might be something completely different.

BTW:

Version: 1.63.0-insider Commit: c1f2f40bcd81380bf2e286af64becddada57db88 Date: 2021-11-24T07:59:15.031Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Linux x64 5.4.0-90-generic

jkpubsrc commented 2 years ago

Don't know if it helps, but here is another detail: Sometimes (!) if I try to refactor-rename a variable or method, the edit field appears, I enter the new identifier, press enter and then I get a short error notice about some kind of internal error. No refactoring is done in this case. And a few moments later (indeterministic) I then get the out of memory error.

Update: Seems to be MUCH more stable if I avoid refactoring at all.

snjeza commented 2 years ago

@jkpubsrc could you, please, attach Java LS log - Enable logging

jkpubsrc commented 2 years ago

I'll try that. Please be patient.

devforma commented 2 years ago

Same problem

Version: 1.65.0 (Universal) Commit: b5205cc8eb4fbaa726835538cd82372cc0222d43 Date: 2022-03-02T11:11:20.886Z (5 days ago) Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin arm64 21.3.0

settings.json

{
    "java.configuration.maven.userSettings": "/Users/mabingtao/maven/maven.xml",
    "java.configuration.updateBuildConfiguration": "automatic",
    "java.trace.server": "verbose"
}

log

!SESSION 2022-03-08 11:34:32.580 -----------------------------------------------
eclipse.buildId=unknown
java.version=17.0.2
java.vendor=Eclipse Adoptium
BootLoader constants: OS=macosx, ARCH=aarch64, WS=cocoa, NL=zh_CN_#Hans
Command-line arguments:  -data /Users/mabingtao/Library/Application Support/Code/User/workspaceStorage/e040ab4c86a48e38b89e79e6b1ccd103/redhat.java/jdt_ws

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:33.480
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:33.584
!MESSAGE Main thread is waiting

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:33.601
!MESSAGE >> initialize

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:33.602
!MESSAGE Initializing Java Language Server 1.9.0.202203030203

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.299
!MESSAGE Default VM Install changed from  null to 1646710474297-/Users/mabingtao/.vscode/extensions/redhat.java-1.4.0/jre/17.0.2-macosx-aarch64

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.308
!MESSAGE Setting java.home /Users/mabingtao/Library/Java/JavaVirtualMachines/zulu11.54.25-ca-jdk11.0.14.1/zulu-11.jdk/Contents/Home as default global VM

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.310
!MESSAGE Default VM Install changed from  1646710474297-/Users/mabingtao/.vscode/extensions/redhat.java-1.4.0/jre/17.0.2-macosx-aarch64 to 1646710474307-/Users/mabingtao/Library/Java/JavaVirtualMachines/zulu11.54.25-ca-jdk11.0.14.1/zulu-11.jdk/Contents/Home

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.321
!MESSAGE JVM Runtimes changed, saving new configuration

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.328
!MESSAGE Static Commands: []

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.329
!MESSAGE Non-Static Commands: [java.edit.organizeImports, java.project.refreshDiagnostics, java.project.import, java.navigate.openTypeHierarchy, java.project.removeFromSourcePath, java.project.listSourcePaths, java.project.resolveStackTraceLocation, java.project.getAll, java.project.isTestFile, java.project.getClasspaths, java.navigate.resolveTypeHierarchy, java.edit.stringFormatting, java.project.getSettings, java.project.updateSourceAttachment, java.project.upgradeGradle, java.project.resolveSourceAttachment, java.project.addToSourcePath]

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.329
!MESSAGE Static Commands: []

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.329
!MESSAGE Non-Static Commands: [vscode.java.checkProjectSettings, vscode.java.isOnClasspath, vscode.java.fetchUsageData, vscode.java.validateLaunchConfig, vscode.java.resolveInlineVariables, vscode.java.resolveClassFilters, vscode.java.resolveMainMethod, vscode.java.resolveClasspath, vscode.java.resolveBuildFiles, vscode.java.resolveMainClass, vscode.java.updateDebugSettings, vscode.java.resolveSourceUri, vscode.java.fetchPlatformSettings, vscode.java.buildWorkspace, vscode.java.startDebugSession, vscode.java.inferLaunchCommandLength, vscode.java.resolveElementAtSelection, vscode.java.resolveJavaExecutable]

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.333
!MESSAGE Wait for AutoBuildOffJob start

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.347
!MESSAGE Wait for AutoBuildOffJob end 14ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.348
!MESSAGE Starting org.eclipse.m2e.core

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.348
!MESSAGE Started org.eclipse.m2e.core 1ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.348
!MESSAGE ProjectRegistryRefreshJob finished 0ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.348
!MESSAGE Starting org.eclipse.buildship.core

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.360
!MESSAGE Started org.eclipse.buildship.core 12ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.374
!MESSAGE LoadingGradleVersionJob finished 12ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.383
!MESSAGE Creating the Java project jdt.ls-java-project

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.387
!MESSAGE >> initialized

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.435
!MESSAGE Finished creating the Java project jdt.ls-java-project

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:34.775
!MESSAGE Importing Maven project(s)

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:36.886
!MESSAGE Workspace initialized in 2511ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:36.911
!MESSAGE >> initialization job finished

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:36.936
!MESSAGE >> workspace/didChangeConfiguration

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:36.940
!MESSAGE >> New configuration: {java={home=/Users/mabingtao/Library/Java/JavaVirtualMachines/zulu11.54.25-ca-jdk11.0.14.1/zulu-11.jdk/Contents/Home, jdt={ls={java={home=null}, vmargs=-javaagent:/Users/mabingtao/lombok.jar -javaagent:"/Users/mabingtao/.vscode/extensions/gabrielbb.vscode-lombok-1.0.1/server/lombok.jar"}}, errors={incompleteClasspath={severity=warning}}, configuration={checkProjectSettingsExclusions=false, updateBuildConfiguration=automatic, maven={userSettings=/Users/mabingtao/maven/maven.xml, globalSettings=null, notCoveredPluginExecutionSeverity=warning}, workspaceCacheLimit=90.0, runtimes=[]}, trace={server=verbose}, import={maven={enabled=true}, gradle={enabled=true, wrapper={enabled=true}, version=null, home=null, java={home=null}, offline={enabled=false}, arguments=null, jvmArguments=null, user={home=null}}, exclusions=[**/node_modules/**, **/.metadata/**, **/archetype-resources/**, **/META-INF/maven/**], generatesMetadataFilesAtProjectRoot=false}, maven={downloadSources=false, updateSnapshots=false}, eclipse={downloadSources=false}, referencesCodeLens={enabled=false}, signatureHelp={enabled=false}, implementationsCodeLens={enabled=false}, format={enabled=true, settings={url=null, profile=null}, comments={enabled=true}, onType={enabled=true}, insertSpaces=true, tabSize=4.0}, saveActions={organizeImports=false}, project={referencedLibraries=[lib/**/*.jar], importOnFirstTimeStartup=automatic, importHint=true, resourceFilters=[node_modules, .git]}, contentProvider={preferred=null}, autobuild={enabled=true}, maxConcurrentBuilds=1.0, recommendations={dependency={analytics={show=true}}}, completion={maxResults=0.0, enabled=true, overwrite=true, guessMethodArguments=false, favoriteStaticMembers=[org.junit.Assert.*, org.junit.Assume.*, org.junit.jupiter.api.Assertions.*, org.junit.jupiter.api.Assumptions.*, org.junit.jupiter.api.DynamicContainer.*, org.junit.jupiter.api.DynamicTest.*, org.mockito.Mockito.*, org.mockito.ArgumentMatchers.*, org.mockito.Answers.*], filteredTypes=[java.awt.*, com.sun.*, sun.*, jdk.*, org.graalvm.*, io.micrometer.shaded.*], importOrder=[java, javax, com, org]}, foldingRange={enabled=true}, progressReports={enabled=true}, codeGeneration={hashCodeEquals={useJava7Objects=false, useInstanceof=false}, useBlocks=false, generateComments=false, toString={template=${object.className} [${member.name()}=${member.value}, ${otherMembers}], codeStyle=STRING_CONCATENATION, skipNullValues=false, listArrayContents=true, limitElements=0.0}, insertionLocation=afterCursor}, selectionRange={enabled=true}, showBuildStatusOnStart={enabled=notification}, server={launchMode=Hybrid}, sources={organizeImports={starThreshold=99.0, staticStarThreshold=99.0}}, imports={gradle={wrapper={checksums=[]}}}, templates={fileHeader=[], typeComment=[]}, references={includeAccessors=true, includeDecompiledSources=true}, typeHierarchy={lazyLoad=false}, settings={url=null}, symbols={includeSourceMethodDeclarations=false}, quickfix={showAt=line}, debug={logLevel=warn, settings={showHex=false, showStaticVariables=false, showQualifiedNames=false, showLogicalStructure=true, showToString=true, maxStringLength=0.0, numericPrecision=0.0, hotCodeReplace=manual, enableRunDebugCodeLens=true, forceBuildBeforeLaunch=true, onBuildFailureProceed=false, console=integratedTerminal, exceptionBreakpoint={skipClasses=[]}, stepping={skipClasses=[], skipSynthetics=false, skipStaticInitializers=false, skipConstructors=false}, jdwp={limitOfVariablesPerJdwpRequest=100.0, requestTimeout=3000.0}, vmArgs=}}, silentNotification=false}}

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:36.942
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:37.308
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:37.594
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:37.714
!MESSAGE Reconciled 1. Took 0 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.189
!MESSAGE begin problem for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.189
!MESSAGE 4 problems reported for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.220
!MESSAGE Validated 1. Took 135 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.244
!MESSAGE >> build jobs finished

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.247
!MESSAGE >> workspace/executeCommand java.project.getAll

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.250
!MESSAGE >> registerWatchers'

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.253
!MESSAGE >> registerFeature 'workspace/didChangeWatchedFiles'

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.254
!MESSAGE >> watchers registered

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.257
!MESSAGE >> workspace/executeCommand java.project.getSettings

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.456
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.486
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:38.506
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY java-debug 1 0 2022-03-08 11:34:38.509
!MESSAGE Starting com.microsoft.java.debug.plugin

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:39.972
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:39.977
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.477
!MESSAGE >> document/hover

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.605
!MESSAGE >> document/documentHighlight

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.778
!MESSAGE >> document/didChange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.783
!MESSAGE >> document/completion

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.789
!MESSAGE Reconciled 1. Took 5 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.856
!MESSAGE Completion request completed

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.877
!MESSAGE >> document/resolveCompletionItem

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:40.969
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.024
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.025
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.305
!MESSAGE begin problem for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.306
!MESSAGE 2 problems reported for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.308
!MESSAGE Validated 1. Took 117 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.564
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.771
!MESSAGE >> document/willSaveWaitUntil

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.800
!MESSAGE >> document/didSave

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:41.979
!MESSAGE Reconciled 1. Took 1 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:42.121
!MESSAGE >> workspace/didChangeWatchedFiles 

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:42.425
!MESSAGE begin problem for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:42.426
!MESSAGE 2 problems reported for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:42.427
!MESSAGE Validated 1. Took 47 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.026
!MESSAGE >> document/hover

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.075
!MESSAGE >> java/findLinks

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.187
!MESSAGE >> document/documentHighlight

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.328
!MESSAGE >> document/didChange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.339
!MESSAGE Reconciled 1. Took 4 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.344
!MESSAGE >> document/completion

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.350
!MESSAGE Completion request completed

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.359
!MESSAGE >> document/resolveCompletionItem

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.528
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.580
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.781
!MESSAGE begin problem for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.782
!MESSAGE 0 problems reported for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:43.782
!MESSAGE Validated 1. Took 37 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.334
!MESSAGE >> document/willSaveWaitUntil

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.358
!MESSAGE >> document/didSave

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.508
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.547
!MESSAGE >> document/willSaveWaitUntil

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.572
!MESSAGE >> document/didSave

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.577
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.589
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.590
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.655
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.682
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.690
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.691
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:44.888
!MESSAGE >> workspace/didChangeWatchedFiles 

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.011
!MESSAGE Reconciled 1. Took 1 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.462
!MESSAGE begin problem for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.462
!MESSAGE 0 problems reported for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.462
!MESSAGE Validated 1. Took 45 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.504
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.514
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.520
!MESSAGE Reconciled 1. Took 1 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.673
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.725
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.736
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.951
!MESSAGE begin problem for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.951
!MESSAGE 0 problems reported for /MasterService.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.969
!MESSAGE begin problem for /PluginMemoryStoreImpl.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.969
!MESSAGE 0 problems reported for /PluginMemoryStoreImpl.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:45.970
!MESSAGE Validated 2. Took 46 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:46.366
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:46.542
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:46.623
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:52.266
!MESSAGE >> workspace/didChangeWatchedFiles 

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:53.154
!MESSAGE >> workspace/didChangeWatchedFiles 

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:55.810
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:55.863
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:55.872
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:34:55.872
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:35:07.674
!MESSAGE Parent process stopped running, forcing server exit

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:35:07.674
!MESSAGE Shutdown received... waking up main thread

!ENTRY java-debug 1 0 2022-03-08 11:35:07.686
!MESSAGE Stopping com.microsoft.java.debug.plugin

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:35:07.687
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is stopping:

!ENTRY org.eclipse.jdt.core 4 4 2022-03-08 11:35:08.214
!MESSAGE Failed to save JDT index: Index for /plugin-master-service
!STACK 0
java.io.IOException: Failed to read index data from file:/Users/mabingtao/Library/Application%20Support/Code/User/workspaceStorage/e040ab4c86a48e38b89e79e6b1ccd103/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core/358424085.index at offset 327 and size 1937010546
    at org.eclipse.jdt.internal.core.index.DiskIndex.readCategoryTable(DiskIndex.java:685)
    at org.eclipse.jdt.internal.core.index.DiskIndex.mergeCategory(DiskIndex.java:485)
    at org.eclipse.jdt.internal.core.index.DiskIndex.mergeCategories(DiskIndex.java:477)
    at org.eclipse.jdt.internal.core.index.DiskIndex.mergeWith(DiskIndex.java:579)
    at org.eclipse.jdt.internal.core.index.Index.save(Index.java:230)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndex(IndexManager.java:1143)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndexes(IndexManager.java:1201)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.notifyIdle(IndexManager.java:819)
    at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:422)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
    at org.eclipse.jdt.internal.compiler.util.HashtableOfObject.<init>(HashtableOfObject.java:56)
    at org.eclipse.jdt.internal.core.index.DiskIndex.readCategoryTable(DiskIndex.java:681)
    ... 9 more

!ENTRY org.eclipse.core.resources 2 10035 2022-03-08 11:35:08.833
!MESSAGE The workspace will exit with unsaved changes in this session.

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:22.969
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:34.917
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:35.913
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:35.983
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:35.999
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.000
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.110
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.148
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.155
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.156
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.266
!MESSAGE >> document/hover

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.277
!MESSAGE >> java/findLinks

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.556
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.577
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.578
!MESSAGE ClassFile contents request completed

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.586
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.586
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.696
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.709
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.710
!MESSAGE ClassFile contents request completed

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.719
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:36.719
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:43.061
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:43.501
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:46.704
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:46.964
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:47.699
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:47.876
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:47.931
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:47.956
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:48.180
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:48.360
!MESSAGE >> document/foldingRange

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:48.413
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:36:48.436
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:38:56.734
!MESSAGE >> document/hover

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:38:56.735
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:38:56.778
!MESSAGE >> java/findLinks

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:38:57.125
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:38:57.278
!MESSAGE >> document/hover

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:38:57.300
!MESSAGE >> java/findLinks

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:38:58.734
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:42.195
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:42.583
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:57.514
!MESSAGE >> document/hover

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:57.580
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:57.617
!MESSAGE >> java/findLinks

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:58.006
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:58.028
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:39:58.031
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:40:00.817
!MESSAGE >> document/hover

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:40:00.853
!MESSAGE >> java/findLinks

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:40:00.873
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:40:01.150
!MESSAGE >> document/definition

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:40:01.181
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:40:01.183
!MESSAGE >> document/didClose

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:42:30.596
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:42:35.941
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:42:37.847
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-08 11:42:38.352
!MESSAGE >> document/codeAction
rgrunber commented 2 years ago

https://bugs.eclipse.org/bugs/show_bug.cgi?id=578211 improved the logging of this, so at least we now know what file is causing it.

/Users/mabingtao/Library/Application%20Support/Code/User/workspaceStorage/e040ab4c86a48e38b89e79e6b1ccd103/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core/358424085.index at offset 327 and size 1937010546

Offsets have changed a bit but I suspect it's failing at https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java#n682 . One of the category tables of the index needs a massive amount of space to be read into memory.

1937010546 (requested size to new HashtableOfObject(size)) 2147483645 (MAX_ARRAY_SIZE for JVM as set by JDT)

What is the size of 358424085.index ? What happens if clean the language server workspace and do a rebuild ? Does the problem continue the same every time ?

devforma commented 2 years ago

size of 358424085.index is 7973Bytes

devforma commented 2 years ago

oom again

filesize of 2995036876.index is 9165Byte

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-03-10 20:58:06.523
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is stopping:

!ENTRY org.eclipse.jdt.core 4 4 2022-03-10 20:58:06.808
!MESSAGE Failed to save JDT index: Index for /route-service
!STACK 0
java.io.IOException: Failed to read index data from file:/Users/mabingtao/Library/Application%20Support/Code/User/workspaceStorage/e462cfedb38c4a978e763b3ce4c9c764/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core/2995036876.index at offset 1065 and size 1952805459
    at org.eclipse.jdt.internal.core.index.DiskIndex.readCategoryTable(DiskIndex.java:685)
    at org.eclipse.jdt.internal.core.index.DiskIndex.mergeCategory(DiskIndex.java:485)
    at org.eclipse.jdt.internal.core.index.DiskIndex.mergeCategories(DiskIndex.java:477)
    at org.eclipse.jdt.internal.core.index.DiskIndex.mergeWith(DiskIndex.java:579)
    at org.eclipse.jdt.internal.core.index.Index.save(Index.java:230)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndex(IndexManager.java:1143)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndexes(IndexManager.java:1201)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.notifyIdle(IndexManager.java:819)
    at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:422)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
    at org.eclipse.jdt.internal.compiler.util.HashtableOfObject.<init>(HashtableOfObject.java:56)
    at org.eclipse.jdt.internal.core.index.DiskIndex.readCategoryTable(DiskIndex.java:681)
    ... 9 more

!ENTRY org.eclipse.jdt.core 4 0 2022-03-10 20:58:06.809
!MESSAGE Failed to update qualified index.
!STACK 0
java.io.IOException: Stream was closed for index location "file:/Users/mabingtao/Library/Application%20Support/Code/User/workspaceStorage/e462cfedb38c4a978e763b3ce4c9c764/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index"
    at org.eclipse.jdt.internal.core.index.DiskIndex.readChunk(DiskIndex.java:751)
    at org.eclipse.jdt.internal.core.index.DiskIndex.readAllDocumentNames(DiskIndex.java:640)
    at org.eclipse.jdt.internal.core.index.DiskIndex.mergeWith(DiskIndex.java:532)
    at org.eclipse.jdt.internal.core.index.Index.save(Index.java:230)
    at org.eclipse.jdt.internal.core.index.MetaIndex.save(MetaIndex.java:100)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveMetaIndex(IndexManager.java:1248)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndexes(IndexManager.java:1224)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.notifyIdle(IndexManager.java:819)
    at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:422)
    at java.base/java.lang.Thread.run(Unknown Source)
devanpedrik commented 8 months ago

I am currently using the extension and facing this issue as well, are there any updates regarding the out of memory issue?

rgrunber commented 8 months ago

I am currently using the extension and facing this issue as well, are there any updates regarding the out of memory issue?

Is vscode-java just notifying that it ran out of memory, and recommending to increase XmX ? Does the log file accessed from Java: Open Java Language Server Log File show any errors related to the index file, or how the process ran out of memory ?

Once we update to a version of JDT that uses https://github.com/eclipse-jdt/eclipse.jdt.core/issues/460, it might be worth trying to see if the problem goes away for those whose index files might have gotten corrupted somehow.

devanpedrik commented 8 months ago

Is vscode-java just notifying that it ran out of memory, and recommending to increase XmX ? Does the log file accessed from Java: Open Java Language Server Log File show any errors related to the index file, or how the process ran out of memory ?

Once we update to a version of JDT that uses eclipse-jdt/eclipse.jdt.core#460, it might be worth trying to see if the problem goes away for those whose index files might have gotten corrupted somehow.

Yes when the oom occur, the popup suggested to increase the memory which I see usually update it by 2G.

Relevant stack trace:

!ENTRY org.eclipse.jdt.core 4 4 2024-02-23 08:23:13.732
!MESSAGE Search failed for index Index for <Project>
!STACK 0
java.io.IOException: Failed to read index data from file:/C:/Users/<myuser>/AppData/Roaming/Code/User/workspaceStorage/9320603dd5db333017f6a472c31fd2d3/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core/3414303982.index at offset 550389 and size 779578678
at org.eclipse.jdt.internal.core.index.DiskIndex.readCategoryTable(DiskIndex.java:680)
    at org.eclipse.jdt.internal.core.index.DiskIndex.addQueryResults(DiskIndex.java:239)
    at org.eclipse.jdt.internal.core.index.Index.query(Index.java:169)
    at org.eclipse.jdt.internal.core.search.matching.SecondaryTypeDeclarationPattern.queryIn(SecondaryTypeDeclarationPattern.java:47)
    at org.eclipse.jdt.core.search.SearchPattern.findIndexMatches(SearchPattern.java:2517)
    at org.eclipse.jdt.core.search.SearchPattern.findIndexMatches(SearchPattern.java:2489)
    at org.eclipse.jdt.internal.core.search.matching.MatchLocator.findIndexMatches(MatchLocator.java:309)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.search(PatternSearchJob.java:240)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.search(PatternSearchJob.java:214)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.lambda$0(PatternSearchJob.java:150)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.awaitDone(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.get(Unknown Source)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.performParallelSearch(PatternSearchJob.java:156)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.execute(PatternSearchJob.java:117)
    at org.eclipse.jdt.internal.core.search.processing.JobManager.performConcurrentJob(JobManager.java:287)
    at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchAllSecondaryTypeNames(BasicSearchEngine.java:1710)
    at org.eclipse.jdt.internal.core.JavaModelManager.secondaryTypesSearching(JavaModelManager.java:5178)
    at org.eclipse.jdt.internal.core.JavaModelManager.secondaryTypes(JavaModelManager.java:5026)
    at org.eclipse.jdt.internal.core.search.matching.ClasspathSourceDirectory.directoryTable(ClasspathSourceDirectory.java:82)
    at org.eclipse.jdt.internal.core.search.matching.ClasspathSourceDirectory.isPackage(ClasspathSourceDirectory.java:148)
    at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.getModulesDeclaringPackage(JavaSearchNameEnvironment.java:501)
    at org.eclipse.jdt.internal.compiler.env.IModuleAwareNameEnvironment.getUniqueModulesDeclaringPackage(IModuleAwareNameEnvironment.java:113)
    at org.eclipse.jdt.internal.compiler.lookup.ModuleBinding$UnNamedModule.getDeclaredPackage(ModuleBinding.java:102)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPlainPackage(LookupEnvironment.java:1105)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:138)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:505)
    at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.resolveDocument(SourceIndexer.java:170)
    at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.resolveDocument(JavaSearchParticipant.java:116)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexResolvedDocument(IndexManager.java:680)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager$2.execute(IndexManager.java:1291)
    at org.eclipse.jdt.internal.core.search.processing.JobManager.indexerLoop(JobManager.java:542)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
    at org.eclipse.jdt.internal.compiler.util.HashtableOfObject.<init>(HashtableOfObject.java:57)
    at org.eclipse.jdt.internal.core.index.DiskIndex.readCategoryTable(DiskIndex.java:676)
    at org.eclipse.jdt.internal.core.index.DiskIndex.addQueryResults(DiskIndex.java:239)
    at org.eclipse.jdt.internal.core.index.Index.query(Index.java:169)
    at org.eclipse.jdt.internal.core.search.matching.SecondaryTypeDeclarationPattern.queryIn(SecondaryTypeDeclarationPattern.java:47)
    at org.eclipse.jdt.core.search.SearchPattern.findIndexMatches(SearchPattern.java:2517)
    at org.eclipse.jdt.core.search.SearchPattern.findIndexMatches(SearchPattern.java:2489)
    at org.eclipse.jdt.internal.core.search.matching.MatchLocator.findIndexMatches(MatchLocator.java:309)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.search(PatternSearchJob.java:240)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.search(PatternSearchJob.java:214)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.lambda$0(PatternSearchJob.java:150)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob$$Lambda$646/0x000000010084dc50.call(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.awaitDone(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.get(Unknown Source)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.performParallelSearch(PatternSearchJob.java:156)
    at org.eclipse.jdt.internal.core.search.PatternSearchJob.execute(PatternSearchJob.java:117)
    at org.eclipse.jdt.internal.core.search.processing.JobManager.performConcurrentJob(JobManager.java:287)
    at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchAllSecondaryTypeNames(BasicSearchEngine.java:1710)
    at org.eclipse.jdt.internal.core.JavaModelManager.secondaryTypesSearching(JavaModelManager.java:5178)
    at org.eclipse.jdt.internal.core.JavaModelManager.secondaryTypes(JavaModelManager.java:5026)
    at org.eclipse.jdt.internal.core.search.matching.ClasspathSourceDirectory.directoryTable(ClasspathSourceDirectory.java:82)
    at org.eclipse.jdt.internal.core.search.matching.ClasspathSourceDirectory.isPackage(ClasspathSourceDirectory.java:148)
    at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.getModulesDeclaringPackage(JavaSearchNameEnvironment.java:501)
    at org.eclipse.jdt.internal.compiler.env.IModuleAwareNameEnvironment.getUniqueModulesDeclaringPackage(IModuleAwareNameEnvironment.java:113)
    at org.eclipse.jdt.internal.compiler.lookup.ModuleBinding$UnNamedModule.getDeclaredPackage(ModuleBinding.java:102)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPlainPackage(LookupEnvironment.java:1105)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:138)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:505)
    at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.resolveDocument(SourceIndexer.java:170)
    at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.resolveDocument(JavaSearchParticipant.java:116)

This occur during initial startup of vscode where my project is getting built.

Findings:

  1. I found out that I will need to set my vmargs on workspace level with high enough -xmx value which in my case I just set it to 8192m where if I do not set it it will provide a default value of 896m which might be the cause for the java heap size oom error as 819m is quite small.
  2. It seems that vmargs setting is not supported on user profile setting? I see that whenever I reload the profile, the settings does not appear in my profile setting anymore. So, is it expected that I should set the vmargs on workspace level everytime?

image

Based on https://code.visualstudio.com/docs/getstarted/settings it states that user setting is a global setting used by all vscode instance which would make sense for setting the vmargs across all instance rather than having to set it everytime a new workspace is created. But user setting is just not working for me as it will remove itself when I import the user profile again.

You mentioned that "once we updated to a version of JDT that uses eclipse-jdt/eclipse.jdt.core#460, the problem might go away". Does this mean that the current version does not include this yet? If it is not yet included, when will it be included?

rgrunber commented 8 months ago
  1. I found out that I will need to set my vmargs on workspace level with high enough -xmx value which in my case I just set it to 8192m where if I do not set it it will provide a default value of 896m which might be the cause for the java heap size oom error as 819m is quite small.

Does the opened folder in your workspace contain a .vscode/settings.json file that sets java.jdt.ls.vmargs ? By default vscode-java will set -XmX1G but if your project contains a settings file that overrides it, that might be a reason it's set to 896m

  1. It seems that vmargs setting is not supported on user profile setting? I see that whenever I reload the profile, the settings does not appear in my profile setting anymore. So, is it expected that I should set the vmargs on workspace level everytime?

It should be possible to use the setting from a profile, as long as it's not overridden by a workspace setting. There's an extra precaution where java.jdt.ls.vmargs from a workspace will only apply if you trust the workspace. Otherwise the user setting will be used.

You mentioned that "once we updated to a version of JDT that uses eclipse-jdt/eclipse.jdt.core#460, the problem might go away". Does this mean that the current version does not include this yet? If it is not yet included, when will it be included?

Yes, currently we don't include that fix. You would likely see it in the next release (1.29.0) scheduled for mid-March. If you switch to the vscode-java pre-release, you may see it even earlier. Once I make the update, I plan to ask on here whether the pre-release solves the issue for anyone.

devanpedrik commented 8 months ago

Does the opened folder in your workspace contain a .vscode/settings.json file that sets java.jdt.ls.vmargs ? By default vscode-java will set -XmX1G but if your project contains a settings file that overrides it, that might be a reason it's set to 896m

Yeah it was generated when I first add in the project folder into vscode but then I deleted it since I assume that if I setup a user profile with all the settings that I needed then it will work fine. So, I'm not sure exactly what set the vmargs to 896m since I've modified it in my user settings which gets removed everytime I load the profile.

It should be possible to use the setting from a profile, as long as it's not overridden by a workspace setting. There's an extra precaution where java.jdt.ls.vmargs from a workspace will only apply if you trust the workspace. Otherwise the user setting will be used.

So do you mean that if I remove the vmargs settings from my workspace setting then the vmargs set in the user profile would not be removed? Then, all I need to do is removing the workspace setting and only use the settings set by user profile. Am I understanding this correctly?

Yes, currently we don't include that fix. You would likely see it in the next release (1.29.0) scheduled for mid-March. If you switch to the vscode-java pre-release, you may see it even earlier. Once I make the update, I plan to ask on here whether the pre-release solves the issue for anyone.

Alright, thank you very much for the clarification.

rgrunber commented 8 months ago

It should be possible to use the setting from a profile, as long as it's not overridden by a workspace setting. There's an extra precaution where java.jdt.ls.vmargs from a workspace will only apply if you trust the workspace. Otherwise the user setting will be used.

So do you mean that if I remove the vmargs settings from my workspace setting then the vmargs set in the user profile would not be removed? Then, all I need to do is removing the workspace setting and only use the settings set by user profile. Am I understanding this correctly?

Yes. I think user profile settings are simply user settings that can be switched in/out based on whichever profile is active. See https://code.visualstudio.com/docs/getstarted/settings#_settings-precedence for an explanation of setting precedence.

We now have a pre-release of vscode-java (v1.29.2024022908) in the marketplaces that should contain the change that automatically deletes a broken index. I'm not sure if this will fix some of the java.io.IOException: Failed to read index data from ... OOM issues described here, but if anyone is still able to reproduce, it would be nice to try using the pre-release stream.

relikd commented 5 months ago

but if anyone is still able to reproduce,

Am I right to assume that the current (non pre-release) version 1.31.0 includes the fix? If so, I still get the popup regularly.

log.txt

rgrunber commented 5 months ago

@relikd , yeah, in fact I can see the fix due to :

[Warn  - 3:34:30 PM] Jun 12, 2024, 3:34:30 PM Java Index broken - will be automatically deleted to repair: file:/Users/USER/Library/Application%20Support/Code/User/workspaceStorage/41dcf427ed1d79663dae541a2fb0aa8f/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core/4253678928.index

which apparently fails because the file doesn't exist. Does opening the command palette and running Java: Clean Java Language Server Workspace make the issue go away ? Does this always happen, or only on a specific project. Are you able to share the project ?

relikd commented 5 months ago

No, Clean Workspace does not help. I have this issue for a few months now and have to clean regularly. Additionally: The main issue for me is that the language server fails often. In order to restore code completion, syntax highlight, etc., I have to restart the language server very often. In fact, sometimes it is so bad, that VSCode will prevent me from pasting code. I see a spinner and it takes more than 15s until I press ESC to abort the paste process (probably a separate issue, though I am too lazy to create a ticket). When it gets so bad, the popup shows almost alway after I restart the language server. Sometimes accompanied by a "could not restart language server" error message. But regardless of the error message, the mentioned issues quiet down for some time. I would say it takes somewhere between 30 minutes to 2 hours until the problem returns.

Unfortunately, I cannot share any project. But if I remember correctly, it was not related to a specific project.

But maybe this helps: after I created this issue, I took a look in the /Users/USER/Library/Application Support/Code/User/ folder. I noticed that History and workspaceStorage folders were quite large. I can't remember exactly but one was ~2GB and the other ~500MB. So, I deleted History and my feeling is, that it helped. I worked for 2–3 hours without a problem. Then I deleted workspaceStorage (just to be safe) and worked for another 3–4 hours without a problem. I will observe this in the next few days and report if the issue occurs again.

relikd commented 4 months ago

Update: The plugin worked fine Friday and today until now. VSCode got laggy again and after a Language Server restart, the popup showed up again. Looking at the folder sizes, History is still small, but workspaceStorage grew to 420MB. ... actually I tried to delete the folder now but it just recreates the whole index. Maybe it is a false lead then.

... as for the project: it is a variation of the HAPI Fhir starter project. Though I doubt it will show the problematic symptoms right away.