[FS Internetradio] OutOfMemory Leaks with openHAB 2?

I am using openHAB 2 on a DS214play (2.0.0.001-DSM6) and bought some Silvercrest SMRS 35 A1 and a SMRB 40 A1 with FS chip. Everything is starting and being controlled perfectly. But after a couple of hours, less than one day, there is an interruption and errors coming up.

First:
> 2017-06-18 14:09:48.268 [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_91]
at java.util.concurrent.FutureTask.get(FutureTask.java:206)[:1.8.0_91]
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_91]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_91]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_91]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_91]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)[:1.8.0_91]
at java.lang.Thread.start(Thread.java:714)[:1.8.0_91]
at org.eclipse.smarthome.core.common.QueueingThreadPoolExecutor.addToQueue(QueueingThreadPoolExecutor.java:115)
at org.eclipse.smarthome.core.common.QueueingThreadPoolExecutor.execute(QueueingThreadPoolExecutor.java:156)
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

and later I get a lot of them:

2017-06-18 14:10:45.534 [WARN ] [tty.util.component.AbstractLifeCycle] - FAILED HttpClient@1002072{FAILED,8<=1<=200,i=1,q=0}: java.lang.OutOfMemoryError: unable to create new native thread
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)[:1.8.0_91]
at java.lang.Thread.start(Thread.java:714)[:1.8.0_91]
at org.eclipse.jetty.util.thread.QueuedThreadPool.startThreads(QueuedThreadPool.java:447)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.jetty.util.thread.QueuedThreadPool.doStart(QueuedThreadPool.java:106)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.jetty.client.HttpClient.doStart(HttpClient.java:229)[69:org.eclipse.jetty.client:9.2.19.v20160908]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.smarthome.binding.fsinternetradio.internal.radio.FrontierSiliconRadioConnection.startHttpClient(FrontierSiliconRadioConnection.java:205)[210:org.eclipse.smarthome.binding.fsinternetradio:0.9.0.b4]
at org.eclipse.smarthome.binding.fsinternetradio.internal.radio.FrontierSiliconRadioConnection.doLogin(FrontierSiliconRadioConnection.java:81)[210:org.eclipse.smarthome.binding.fsinternetradio:0.9.0.b4]
at org.eclipse.smarthome.binding.fsinternetradio.internal.radio.FrontierSiliconRadio.login(FrontierSiliconRadio.java:64)[210:org.eclipse.smarthome.binding.fsinternetradio:0.9.0.b4]
at org.eclipse.smarthome.binding.fsinternetradio.handler.FSInternetRadioHandler$2.run(FSInternetRadioHandler.java:144)[210:org.eclipse.smarthome.binding.fsinternetradio:0.9.0.b4]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_91]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_91]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_91]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_91]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_91]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_91]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]

until openHAB crashes (because the system does not respond anymore).

What is it? I am not alone, I think. It seems that @Jens_Zeidler is encountering similiar problems (How to find the cause of a OutOfMemoryError in OH2? - #16 by Jens_Zeidler).

Maybe @paphko can help?

Thanks in advance!

My first guess for the errors is the periodic refresh in combination with some missing code to cleanup old / failed connections.

As you can see in the headers, the code was changed by multiple authors in the meantime, one of the reasons was to replace the http client that was used initially. I am currently not using this binding and I don’t have much spare time, so I cannot really help you at the moment. If this error is reproducible, I would suggest you open an issue with a bug report how it can be reproduced including the stacktraces above and a link to this thread.