OpenHab 4.2.1 stopping after 3 days - OutOfMemoryError

  • Platform information:
    • Hardware: Pi 5 with 8 GB Ram
      • Java Runtime Environment: zulu JDK 17
    • openHAB version: 4.2.1
  • Issue of the topic: hello, since I moved to openHab 4.2.1, openHab is stopping after ~ 3 days, and I have to restart manually. See below what I get with the “status” function:
sudo systemctl status openhab.service 
● openhab.service - openHAB - empowering the smart home
     Loaded: loaded (/lib/systemd/system/openhab.service; disabled; preset: enabled)
     Active: active (running) since Sun 2024-09-29 10:09:40 CEST; 3 days ago
       Docs: https://www.openhab.org/docs/
             https://community.openhab.org
   Main PID: 10670 (java)
      Tasks: 149 (limit: 4915)
        CPU: 13h 59min 43.774s
     CGroup: /system.slice/openhab.service
             └─10670 /usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr/share/openhab -Dopenhab.conf=/etc/openhab -Dopenhab.runtime=/usr/share/openhab/runtime -Dopenhab.userdata=/var/lib/openhab -Dopenhab.logdir=/var/log/openhab -Dfelix.cm.dir=/var/lib/openhab/confi>

Okt 03 09:35:34 raspberrypi karaf[10670]: Exception in thread "OH-common-11044" java.lang.OutOfMemoryError: Java heap space
Okt 03 09:35:34 raspberrypi karaf[10670]: Exception in thread "OH-common-11063" java.lang.OutOfMemoryError: Java heap space
Okt 03 09:35:36 raspberrypi karaf[10670]: Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "OH-common-11053"
Okt 03 09:35:37 raspberrypi karaf[10670]: Exception in thread "OH-scheduler-6169" java.lang.OutOfMemoryError: Java heap space
Okt 03 09:35:37 raspberrypi karaf[10670]: Exception in thread "UDP-Receiver-0.0.0.0/0.0.0.0:5683[0]" java.lang.OutOfMemoryError: Java heap space
Okt 03 09:35:37 raspberrypi karaf[10670]: Exception in thread "jupnp-jetty-client-666" java.lang.OutOfMemoryError: Java heap space
Okt 03 09:36:04 raspberrypi karaf[10670]: Exception in thread ":CoapEndpoint-UDP-224.0.1.187:5683#1" java.lang.OutOfMemoryError: Java heap space
Okt 03 09:36:06 raspberrypi karaf[10670]: Exception in thread "OH-common-11067" Exception in thread "OH-common-11064" java.lang.OutOfMemoryError: Java heap space
Okt 03 09:36:06 raspberrypi karaf[10670]: java.lang.OutOfMemoryError: Java heap space
Okt 03 09:36:23 raspberrypi karaf[10670]: org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : An exception occurred processing Appender OSGI

If anyone has an idea how to solve it, I would be extremely grateful!

Thank you in advance for your expert support!

It has been awhile since there have been reports of OOM problems. The most likely cause is a memory leak in one of your add-ons. The most straight forward way to find it will be to systematically remove add-ons until the memory leak stops and then file an issue on that add-on.

In the mean time you can buy yourself some time between OOM crashes by increasing the max heap allocated to Java when OH starts up. Exactly how you do that will differ depending on how you’ve installed OH. Ultimately it will be supplying -Xmx=1024m (or what ever size you think you may need, I can’t remember what the default is).

The Doctor add-on on the marketplace might provide some useful information here. Among the things it can do is update an Item with the amount of heap in use which you can see in a chart. You can use that to monitor the heap and perhaps tell when the heap stops growing. Beware though that some growth is expected but when garbage collection occurs useage should drop. Over time what it drops to should level out. If the drop continues to grow you know you still have a memory leak.

Thank you Rich for the feedback. I will apply your recommendations!

Could you list the used bindings?

First remove all bindings that were not compiled with your current OH version, that is the bindings you could have installed from the marketplace or jar files you could have put directly in the addons folder.

and just to add to what everyone else is saying
What rules language do your rules use? Check for any changes in that language. Make sure the update didn’t cause one of your rules to have an error. Some recent reports have a faulty rule causing OOM

Good point. If your rules are managed rules a good starting point is to simply open your rules and save them. This forces syntax checking and brings up the result in your GUI (at least for JS, not sure about jruby and others). This functionality was built in not long ago.

1 Like

Hello, I have the following bindings installed:
-Goe Charger
-Hue
-Modbus
-Netatmo
-Shelly
-SomfyTahoma
-HomeConnect
-Logreader
-MyBMW
-Onkyo
-SMA Energymeter
-Telegram

I’m pretty sure the change is generic so checking and reporting should work for all managed rules languages.

2 Likes