OH2 Out of Memory Error: Can't start new threads

Hi all

After OH2 is running without errors I’m getting out of memory errors:

19:30:29.915 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'Office_Light_Top' received command ON
19:30:29.978 [ERROR] [ore.internal.events.OSGiEventManager] - Dispatching/filtering event for subscriber 'org.eclipse.smarthome.core.events.EventSubscriber' failed: java.lang.OutOfMemoryError: unable to create new native thread
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: unable to create new native thread
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)[:1.8.0_131]
	at java.util.concurrent.FutureTask.get(FutureTask.java:206)[:1.8.0_131]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:188)[98:org.eclipse.smarthome.core:0.9.0.b4]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:81)[98:org.eclipse.smarthome.core:0.9.0.b4]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:65)[98:org.eclipse.smarthome.core:0.9.0.b4]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager.dispatchESHEvent(OSGiEventManager.java:188)[98:org.eclipse.smarthome.core:0.9.0.b4]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:163)[98:org.eclipse.smarthome.core:0.9.0.b4]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:146)[98:org.eclipse.smarthome.core:0.9.0.b4]
	at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[6:org.apache.karaf.services.eventadmin:4.0.8]
	at org.apache.felix.eventadmin.impl.tasks.HandlerTask.run(HandlerTask.java:90)[6:org.apache.karaf.services.eventadmin:4.0.8]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_131]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_131]
	at java.lang.Thread.run(Thread.java:748)[:1.8.0_131]
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)[:1.8.0_131]
	at java.lang.Thread.start(Thread.java:717)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1368)[:1.8.0_131]
	at org.eclipse.smarthome.core.common.QueueingThreadPoolExecutor.execute(QueueingThreadPoolExecutor.java:148)
	at org.eclipse.smarthome.core.items.GenericItem.notifyListeners(GenericItem.java:235)
	at org.eclipse.smarthome.core.items.GenericItem.applyState(GenericItem.java:213)
	at org.eclipse.smarthome.core.items.GenericItem.setState(GenericItem.java:199)
	at org.eclipse.smarthome.core.internal.items.ItemUpdater.receiveUpdate(ItemUpdater.java:70)
	at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:44)
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:192)
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)
	at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:179)
	... 4 more

I’m using OH 2.0.0 with knx, Astro and Plex binding on Rasp PI 3.

Has any body an idea how to fix this? Looks like the Java garbage collector is not able to free the memory for cerated threads by executing a rule.

After restarted OH2 everything is good again because the memory was freed.

The error happened, when I turn the light on which triggers a rule to activate / deactivate a LED after approx 6 days.
Thanks in advance for any hint how to solve the issues.

I suggest searching for “OutOfMemoryError” using the forum search capability. You’ll find quite a bit of information about related issues and tools for helping to diagnose the problem.

I saw several posts regarding the same issue but not related to the plugins I’m using.

Sorry, I’m not a Java developer and not able to debug OH2 on my own or use a profiling tool or make memory dump analysis.

It would be helpful if someone cold walk me through the analysis exercise to provide the necessary information for further analyses.

Would an update to OH 2.1.x potentially solve the issue?