Memory Leak MI IO?

hi @marcel_verpaalen

could there be a memory leak in the recent version?

06:27:27.010 [ERROR] [internal.DiscoveryServiceRegistryImpl] - Cannot notify the DiscoveryListener org.eclipse.smarthome.config.discovery.internal.PersistentInbox on Thing discovered event!
java.lang.IllegalStateException: Timer already cancelled.
	at java.util.Timer.sched( ~[?:?]
	at java.util.Timer.schedule( ~[?:?]
	at ~[?:?]
	at ~[?:?]
	at org.eclipse.smarthome.config.discovery.internal.PersistentInbox.add( ~[?:?]
	at org.eclipse.smarthome.config.discovery.internal.PersistentInbox.thingDiscovered( ~[?:?]
	at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl$ ~[?:?]
	at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl$ ~[?:?]
	at Method) ~[?:?]
	at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.thingDiscovered( ~[?:?]
	at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.thingDiscovered( ~[?:?]
	at org.openhab.binding.miio.internal.discovery.MiIoDiscovery.discovered( ~[?:?]
	at org.openhab.binding.miio.internal.discovery.MiIoDiscovery.access$1( ~[?:?]
	at org.openhab.binding.miio.internal.discovery.MiIoDiscovery$ReceiverThread.lambda$0( ~[?:?]
	at java.util.concurrent.Executors$ [?:?]
	at [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201( [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]
	at java.util.concurrent.ThreadPoolExecutor$ [?:?]
	at [?:?]
06:28:07.095 [WARN ] [] - Dispatching event to subscriber '' takes more than 5000ms.
06:27:53.735 [INFO ] [smarthome.event.ItemStateChangedEvent] - LOCALWEATHER_windir changed from 224 to 243
06:30:14.140 [WARN ] [] - Dispatching event to subscriber '' takes more than 5000ms.
06:33:01.137 [WARN ] [] - Dispatching event to subscriber 'org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl@3c26bb' takes more than 5000ms.
06:37:46.534 [WARN ] [] - Dispatching event to subscriber '' takes more than 5000ms.
06:40:38.386 [WARN ] [] - Dispatching event to subscriber '' takes more than 5000ms.
Exception in thread "pool-2339-thread-1" java.lang.OutOfMemoryError: Java heap space07:13:18.242 [WARN ] [] - Dispatching event to subscriber 'org.eclipse.smarthome.core.thing.internal.CommunicationManager@5506dd' takes more than 5000ms.

Exception in thread "Mi IO MessageSenderThread" java.lang.OutOfMemoryError: Java heap space

I don’t think anything changed recently in the miio code…
But indeed this needs to be monitored to understand what’s behind it

Was this a onetime event, or you see this behavior more often?

for the moment it seems like one time event

I did read most of the things … also my MI things

Can it be related it always finds the roborock s50 with 2 entries in auto discovery?

this is expected behavior… there are actually 2 independent methods for discovering devices.
So far I was not able to avoid the double entries in a good way


On my machine the leaking started as well:

I do not think i have updated neither openhab (running on a Raspberry PI) nor the Mi IO - Plugin.
But i do apt update && apt upgade regularly. So maybe this has something to do with the runtime envrironment?

I do use the Oracle JDK:

java version “1.8.0_201”
Java™ SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot™ Client VM (build 25.201-b09, mixed mode)

Any idea?

Kind regards and thanks a lot for the great plugin,


Edit: Just realized that this thread is about memory leaking, not thread leaking.
Should i open a new thread?

I think this is related to

I’m still in the dark on the cause of it…
Are you using text config or the thing via paperUI discovery ?


I´m using text config only on OpenHAb stable / 2.4.0.
It used to work for quiet a few months without any issues.
Then OpenHab stopped responding and needs to be restarted. It keeps on doing so until now.
After every two days or so the number of Mi IO MessageSenderThreads is within several thousands.
Openhab then runs out of memory giving OOM-Exception:

java.lang.OutOfMemoryError: unable to create new native thread

I made a backup of my config and reinstalled OpenHab freshly - no effect. It runs OOM, having high CPU load and thousands of these threads above.

Can i help with anything?



I guess you have in your thing file you have not defined your deviceId
Can you please add the deviceId for your device (you can see it in the parperUI screen).
I expect that will solve your issue. (it is mandatory config in the current version)

1 Like


Your are totally right. Adding the deviceId in the .things-File did the trick.
Just one Mi IO MessageSenderThread lives happily.
The moment i remove the deviceId from the .thing-Config, new Mi IO MessageSenderThreads are spawned (and start to sum up till OOM).

I wonder how you found this one. Thank you very much for your precise help!

Kind regards,