OH4 runs out of memory

IPv6 issue should be fixed, but note that IPv6 is not supported by the binding

Thanks, I’ve installed and am testing.

Sometime in the last couple of days the thread count stopped increasing. Not associated with a config or install change, it just stopped. Which is very unusual. Which is another way of saying that a test may not be proof, if it can just stop increasing on its own without code change. Having said that, it also looks like the message “WebSocket error” also stopped occurring in the log. So presumably if I have that message without thread number change, then it works. I’ll see today if that message is still occurring.

For those who may also want to test, the process here is:

  1. Assuming you’re using apt to install - you want to change your sources.list to include unstable. In my case that’s in /etc/apt/sources.list.d/openhab.list, and the line looks like:
deb [signed-by=/usr/share/keyrings/openhab.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg unstable main
  1. Upgrade, which should give you the snapshot version

  2. Go to the openhab console: ssh -p 8101 openhab@localhost
    (password is habopen)

  3. Turn on trace logging for the binding

log:set TRACE org.openhab.binding.shelly
  1. Upgrade the binding to the version provided by Markus above
[openhab> bundle:list |grep Shelly
280 x Active x  80 x 4.1.0.202310211629     x openHAB Add-ons :: Bundles :: Shelly Binding Gen1+2
[openhab> bundle:update 280 https://github.com/markus7017/myfiles/blob/master/shelly/org.openhab.binding.shelly-4.1.0-SNAPSHOToom.jar?raw=true
  1. I always restart my openhab so I can start clean. sudo service openhab restart

  2. Then you need to get the process id of your openhab instance

ps -ef |grep openhab
  1. Use the process id to get a count of the threads that refer to “WebSocket”
while true; do date; sudo jstack 9868 | grep WebSocket | wc -l; sleep 60; done >> threadcount2.txt &  tail -f threadcount2.txt
  1. Check the openhab log to see if there are any “WebSocket error” messages turning up
fgrep "WebSocket error" /var/log/openhab/openhab.log

That’s about it.

dis you installed the new build?

I did. No errors nor additional threads so far. Would there be anything different in the log that would tell me I’m definitely running the right version?

that‘s the expected behavior :heart_eyes:
check bundle:list if shows you the build timestamp

OK, bundle timestamp: 4.1.0.202310211629

So it’s the new one. Would the changes have removed the WebSocket error, or just caused it to not leak when there was the error? I haven’t seen any discovery messages at all since the upgrade - which fixes it I guess, just not what I expected.

the 2 mentioned above and another one on disconnect handling, which was already merged

Hello @markus7017
I wanted to try it also to test the issue with the Wall Screen but installing the new Jar gives me thi> s error:

Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.shelly-4.1.0-SNAPSHOToom.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.shelly [305]
Unresolved requirement: Import-Package: com.google.gson; version=“[2.10.0,3.0.0)”
at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) ~[?:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) ~[?:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) ~[?:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) ~[?:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) ~[?:?]

Maybe because i’m on OH 4.0.3??

urg, gson is one of the core packages and shpuld be always there

4.0.3 should be fine

try

  • delete the jar, stop OH
  • openhab-cli clean-cache
  • start OH, wait 5min until cache is recreated
  • open OH console
  • enter „ feature:install oh-transport-coap“
  • copy jar to addins folder
  • wait a bit and check with bundle:list that binding is Active

I had that same problem. I resolved it by first upgrading my whole openhab to the latest snapshot release (changing my sources.list to include unstable), then upgrading to the new jar. I think it’s a newer version of gson required - so you have it, but not a new enough version.

I did manually upgrade gson, which you can do, but it then asked for a different jar to be upgraded as well, and I decided I’d be chasing my tail.

Overnight, no new threads created. Working well so far.

I created PR #15198, which includes those fixes. There is a good chance that it also goes into 4.0 (beside next 4.1 milestone build)

I am suffering from oom since 4.0.3. I tried to use your jar without look under 4.0.3. Updated to 4.1 unstable but no luck either. Got massive Exceptions. Is there any special Version of 4.1 to use your jar with ?

I just ran directly against unstable - so I updated using APT to the full unstable, then used the console to update just that one jar using the link provided.

What exception exacatly are you getting? Is it the Gson one?

Updating via console did the trick. Thank you. Fixed my OOMs instantly.

Might be not related since I am still running OH 3.4.4, but I was suffering OOM for few weeks and it was defenetly the Nest binding.
I stopped such binding for several days and solved. Today I restarted it and the out of memory problem came back in few hours.
It’s a real pity that this device had such troubles with account, support and functionality confusion.

This isn’t the nest binding though, it’s the Shelly binding.

I’m juat finalizing the PR

It’s the shelly binding for me too.
Markus’s solution works for me. No more out of memory errors anymore.

PR #15798 is ready to merge, check out: [shelly] Fix resource leak, BLU script installation, TRV init, NPE on IPv6 mDNS discovery by markus7017 · Pull Request #15798 · openhab/openhab-addons · GitHub
which includes OOM Fix #2 and #3 and some other important fixes.
since then you could use https://github.com/markus7017/myfiles/blob/master/shelly/org.openhab.binding.shelly-4.1.0-SNAPSHOToom.jar?raw=true

1 Like