I got a problem with my OH instance. It runs out of memory about every 10 hours. The cause for this is that OH constantly creates new threads and at about 5000 it is not allowed to create more and then fails. To resurrect OH I have to restart the service.
● openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-06-17 23:36:48 CEST; 10h ago
Docs: https://www.openhab.org/docs/ https://community.openhab.org
Main PID: 603 (java) Tasks: 4900 (limit: 4915)
Memory: 889.0M
CGroup: /system.slice/openhab2.service
└─603 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2 -Dfelix.cm.dir=/var/lib/
Jun 18 09:08:57 openhab karaf[603]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
Jun 18 09:08:57 openhab karaf[603]: at java.lang.Thread.run(Thread.java:748)
Jun 18 09:09:00 openhab karaf[603]: Exception in thread “EventThread” java.lang.OutOfMemoryError: unable to create new native thread
Jun 18 09:09:00 openhab karaf[603]: at java.lang.Thread.start0(Native Method)
Jun 18 09:09:00 openhab karaf[603]: at java.lang.Thread.start(Thread.java:717)
Jun 18 09:09:00 openhab karaf[603]: at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:957)
Jun 18 09:09:00 openhab karaf[603]: at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1025)
Jun 18 09:09:00 openhab karaf[603]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
Jun 18 09:09:00 openhab karaf[603]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
Jun 18 09:09:00 openhab karaf[603]: at java.lang.Thread.run(Thread.java:748)
I cant imagine what causes this behaviour. The system is completely up do date.
As said one week ago everything was fine, I did an rpi-eeprom update since then (with apt). Maybe this causes the problem.
Running OH 2.5.5 and java -version
openjdk version “1.8.0_222”
OpenJDK Runtime Environment (Zulu8.40.0.178-CA-linux_aarch32hf) (build 1.8.0_222-b178)
OpenJDK Client VM (Zulu8.40.0.178-CA-linux_aarch32hf) (build 25.222-b178, mixed mode, Evaluation)
I had some similar out of control resource issues (in my case, CPU) a while back, but in the end I chalked it up to old version of OpenHAB and underpowered hardware. Couple guys though gave some pointers on possible things to look for, might be worth a quick scan of the thread. Bruce_Osborne and I got off topic about documentation, just skip over those and go straight here or maybe here.
By now I have some vastly better hardware (ODROID-XU4 as opposed to Cubietruck) and not too long ago re-installed everything fresh from scratch to onboard EMMC (Armbian Stable, OpenHAB Stable 2.5.5, Zulu Java 8 Embedded, etc.) and so far, so good.
I am always afraid of a runaway Java memory/resource eating monster however, so I almost always keep an htop going in a console somewhere, log in frequently and check system load, etc… Now it’s only been few weeks probably, and I still only have very few things added into the new system, however the ODROID-XU4 has yet to so much as break a sweat (I never even seen it above 0.1 load average). I’m curious to see how it goes as my installation grows more complex…
Just out of curiosity, what distro are you running? And how complex is your installation? Anything in particular you remember changing right before this happened? These questions are only necessary if it ends up not being some easy solution as mentioned above.