OutOfMemoryException in SonarLint Eclipse when reading large files

I’m using Eclipse (with a proprietary plugin) to open large profiler files. When SonarLint is installed, I always get an OutOfMemoryError, with the following stack trace:

java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Unknown Source)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)
	at java.lang.AbstractStringBuilder.append(Unknown Source)
	at java.lang.StringBuilder.append(Unknown Source)
	at org.eclipse.core.internal.filebuffers.ResourceTextFileBuffer.setDocumentContent(ResourceTextFileBuffer.java:518)
	at org.eclipse.core.internal.filebuffers.ResourceTextFileBuffer.initializeFileBufferContent(ResourceTextFileBuffer.java:248)
	at org.eclipse.core.internal.filebuffers.ResourceFileBuffer.create(ResourceFileBuffer.java:247)
	at org.eclipse.core.internal.filebuffers.TextFileBufferManager.connect(TextFileBufferManager.java:115)
	at org.sonarlint.eclipse.core.internal.resources.DefaultSonarLintFileAdapter.getDocument(DefaultSonarLintFileAdapter.java:68)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.trackIssues(AbstractAnalyzeProjectJob.java:312)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.updateMarkers(AbstractAnalyzeProjectJob.java:300)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.runAnalysisAndUpdateMarkers(AbstractAnalyzeProjectJob.java:207)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.doRun(AbstractAnalyzeProjectJob.java:167)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractSonarProjectJob.runInWorkspace(AbstractSonarProjectJob.java:44)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

File extension is .prof, which is not handled by any plugin as far as I know, so I think the file shouldn’t be read by SonarLint.

It’s possible to easily reproduce the issue:

  • Create a 200Mb test.prof file (or perhaps larger depending on memory settings)
  • Assign the extension .prof to “No source found” Eclipse editor
  • Open the file. The editor immediately opens (and just displays the name of the file), then SonarLint crashes.

Adding the extension to the file exclusions list didn’t help.

  • Eclipse 2019-03 (4.11.0)
  • SonarLint for Eclipse 4.1.0.201901311043 connected to SonarQube 7.7 (build 23042), developer edition

Thanks for the detailed report @gquerret. I’m very sorry to be so late on replying, I probably missed your post.

Ticket created: https://jira.sonarsource.com/browse/SLE-334

No problem, thanks !

Fix has been released in SonarLint Eclipse 5.0