2

I'm working with eclipse on Windows 7 and after an answer suggested SonarLint for catching problematic code, I installed it and it's working fine (99%).

I now have an issue with specific legacy classes with too many sonar issues (10K lines of bad code).

Eclipse keeps crashing when working on this files, OutOfMemoryError exception in log:

!ENTRY org.eclipse.osgi 4 0 2018-05-14 15:10:40.524
!MESSAGE Application error
!STACK 1
java.lang.OutOfMemoryError: Java heap space

!ENTRY org.eclipse.core.jobs 4 2 2018-05-14 15:10:40.526
!MESSAGE An internal error occurred during: "SonarLint analysis of file MyJava.java".
!STACK 0
java.lang.OutOfMemoryError: Java heap space

!ENTRY org.eclipse.e4.ui.workbench 4 0 2018-05-14 15:10:51.220
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.eclipse.e4.core.di.InjectionException: org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:65)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:966)
    at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:426)
    at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:154)
    at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:78)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:74)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:176)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:161)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:106)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:139)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156)
    at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
    at org.eclipse.osgi.container.Module.doStop(Module.java:634)
    at org.eclipse.osgi.container.Module.stop(Module.java:498)
    at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:202)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:165)
    at java.lang.Thread.run(Unknown Source)

I didn't find way to exclude files in sonarlint plugin.

Is there a way still working with SonarLint and handling such files or is there a different approach/plugin?

I tried adding -XX:+UseCompressedOops but it didn't helped. another configuration:

-Xms512m
-Xmx1024m
Rann Lifshitz
  • 4,040
  • 4
  • 22
  • 42
Ori Marko
  • 56,308
  • 23
  • 131
  • 233

1 Answers1

4

You are in the right direction. We also have Uber files containing more then 10K lines of code in our projects/CRs.

The solution in our case was simple - increase the JVM max heap size to 4GB:

-Xms512m
-Xmx4096m

This solved the probelm for a 13K bad code file that was the cause of the java.lang.OutOfMemoryError exception on our end (using Eclipse Oxygen).

Alterntive solutions? You can configure SonarLint not to scan automatically each Java class which you open in the editor. This way you can manually select your scans and avoid the large file scans.

I recommend increasing the heap size to 4GB, then again my workstation has 16GB of memory.

Rann Lifshitz
  • 4,040
  • 4
  • 22
  • 42