OutOfMemoryError on Pi4 Docker OH 2.5.12 setup

I just recently switched OH from a sorted out Windows laptop to a Raspberry Pi 4 using the default docker image for OH 2.5.12. Unfortunately, now on the 3rd day I get an OutOfMemoryError

  • Platform information:
    • Hardware: Raspberri Pi 4
    • OS: Raspbian
    • Java Runtime Environment: Docker Hub 2.5.12
    • openHAB version: 2.5.12
Exception in thread "OkHttp Dispatcher" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3236)
        at java.lang.StringCoding.safeTrim(StringCoding.java:79)
        at java.lang.StringCoding.access$300(StringCoding.java:50)
        at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:305)
        at java.lang.StringCoding.encode(StringCoding.java:344)
        at java.lang.StringCoding.encode(StringCoding.java:387)
        at java.lang.String.getBytes(String.java:958)
        at org.eclipse.smarthome.storage.json.internal.JsonStorage.writeDatabaseFile(JsonStorage.java:271)
        at org.eclipse.smarthome.storage.json.internal.JsonStorage.flush(JsonStorage.java:302)
        at org.eclipse.smarthome.storage.json.internal.JsonStorage.deferredCommit(JsonStorage.java:345)
        at org.eclipse.smarthome.storage.json.internal.JsonStorage.put(JsonStorage.java:142)
        at org.openhab.binding.homeconnect.internal.logger.LogWriter.writeLog(LogWriter.java:192)
        at org.openhab.binding.homeconnect.internal.logger.LogWriter.log(LogWriter.java:63)
        at org.openhab.binding.homeconnect.internal.logger.LogWriter.debugWithHaId(LogWriter.java:112)
        at org.openhab.binding.homeconnect.internal.client.HomeConnectSseClient$1.onMessage(HomeConnectSseClient.java:118)
        at com.here.oksse.RealServerSentEvent$Reader.dispatchEvent(RealServerSentEvent.java:239)
        at com.here.oksse.RealServerSentEvent$Reader.processLine(RealServerSentEvent.java:208)
        at com.here.oksse.RealServerSentEvent$Reader.read(RealServerSentEvent.java:185)
        at com.here.oksse.RealServerSentEvent.openSse(RealServerSentEvent.java:94)
        at com.here.oksse.RealServerSentEvent.access$100(RealServerSentEvent.java:26)
        at com.here.oksse.RealServerSentEvent$1.onResponse(RealServerSentEvent.java:79)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:174)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Exception in thread "Timer-45" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3236)
        at java.lang.StringCoding.safeTrim(StringCoding.java:79)
        at java.lang.StringCoding.access$300(StringCoding.java:50)
        at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:305)
        at java.lang.StringCoding.encode(StringCoding.java:344)
        at java.lang.StringCoding.encode(StringCoding.java:387)
        at java.lang.String.getBytes(String.java:958)
        at org.eclipse.smarthome.storage.json.internal.JsonStorage.writeDatabaseFile(JsonStorage.java:271)
        at org.eclipse.smarthome.storage.json.internal.JsonStorage.flush(JsonStorage.java:299)
        at org.eclipse.smarthome.storage.json.internal.JsonStorage$CommitTimerTask.run(JsonStorage.java:329)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
Exception in thread "OkHttp Dispatcher" java.lang.OutOfMemoryError: Java heap space
Exception in thread "OkHttp Dispatcher" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Timer-5" java.lang.OutOfMemoryError: Java heap space
Exception in thread "upnp-async-248563" Exception in thread "upnp-async-248588" Exception in thread "upnp-main-474" java.lang.OutOfMemoryError: Java heap space
Exception in thread "upnp-main-2" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-5-thread-1" java.lang.OutOfMemoryError: Java heap space

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-29918"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "openHAB-job-scheduler_QuartzSchedulerThread"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "JmDNS(JmDNS-/192.168.1.39).State.Timer"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "OH-common-6519"
Exception in thread "JmDNS(JmDNS-/192.168.1.55).State.Timer" java.lang.OutOfMemoryError: Java heap space
Exception in thread "SocketListener(JmDNS-/192.168.1.39)" java.lang.OutOfMemoryError: Java heap space
Exception in thread "upnp-main-1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Thread-29829" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-15418-thread-1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "SocketListener(JmDNS-/192.168.1.55)" java.lang.OutOfMemoryError: Java heap space
Exception in thread "OkHttp Dispatcher" java.lang.OutOfMemoryError: Java heap space
Exception in thread "upnp-main-66213" java.lang.OutOfMemoryError: Java heap space
Exception in thread "upnp-main-66215" java.lang.OutOfMemoryError: Java heap space
Exception in thread "upnp-main-66210" java.lang.OutOfMemoryError: Java heap space

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "JmDNS(JmDNS-/192.168.1.39).Timer"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "OH-thingManager-93"
Exception in thread "Karaf Lock Monitor Thread" java.lang.OutOfMemoryError: Java heap space
Exception in thread "OH-thingManager-90" java.lang.OutOfMemoryError: Java heap space
Exception in thread "upnp-async-248589" java.lang.OutOfMemoryError: Java heap space

In the same time the java-process now takes 100% CPU and 11% Memory (of 4GB). OH doesnโ€™t react in this moment anymore and I have to restart the container.

That is not usually a recommended configuration on a Pi due to its limited resources. It may work with a 4GB Pi though.

Many people install openHABian on a Pi. It is a variant od Raspbian with just the needed parts for OH in it.

It is 4 GB, as also mentioned only 11% of memory are actually used by openhab, most is still free.

One of your bindings has a memory leak. Youโ€™ll probably have to use the process of elimination to figure out which one it is. But even once you do, that error wonโ€™t be fixed in 2.5 so youโ€™ll have to find and manually install an older version of that binding that doesnโ€™t have the memory leak or upgrade to OH 3.

Thanks for the info. Iโ€™m anyway currently in the process of migrating to OH3, but good to know :slight_smile:

Which is probably wrong information as I have rarely seen OH use that little mem (and at the same time hit some limit ? Nah.)

You better move over to openHABian, unlike your setup itโ€™s memory optimized and proven.