Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler

Hi,

Starting Groovy-Eclipse compiler resolver. Specified compiler level: unspecifie
d
121 2.4.300.xx-201509250011-e44 = STARTING
log4j:WARN No appenders could be found for logger (org.eclipse.xtext.ui.internal
.Activator).
log4j:WARN Please initialize the log4j system properly.
Jan 27, 2017 2:13:58 PM org.restlet.engine.connector.NetServerHelper start
INFO: Starting the internal [HTTP/1.1] server on port 49330
Jan 27, 2017 2:13:58 PM org.restlet.Application start
INFO: Starting org.bonitasoft.studio.designer.core.WorkspaceApplication applicat
ion
Exception in thread “Worker-4”
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler i
n thread “Worker-4”
Exception in thread “Worker-5”
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler i
n thread “Worker-5”
Exception in thread “Worker-1”
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler i
n thread “Worker-1”
Error while logging event loop exception:
Exception in thread “Worker-6”
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler i
n thread “Worker-6”
Exception in thread “Worker-2”
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler i
n thread “Worker-2”

Usually, this error is thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

Therefore you pretty much have two options:

  • Increase the default memory your program is allowed to use using the -Xmx option (for instance for 1024 MB: -Xmx1024m)
  • Modify your program so that it needs less memory, using less big data structures and getting rid of objects that are not any more used at some point in your program

Increasing the heap size is a bad solution, 100% temporary. It will crash again in somewhere else. To avoid these issues, write high performance code.

  • Use local variables wherever possible.
  • Make sure you select the correct object (EX: Selection between String, StringBuffer and StringBuilder)
  • Use a good code system for your program(EX: Using static variables VS non static variables)
  • Other stuff which could work on your code.
  • Try to move with Multy Threading