[SOLVED] Increasing RAM for Openhab

I am completely new to Openhab, and also to Linux so I have a quite newbie question. As I have Openhab running on my rpi4, there must be a place where all the files and folders are, right? For example the folder that contains all the bindings files? I’m having an issue with java heap memory and think that it is probably a binding that is taking up the memory, but as I cannot access my Openhab dashboard, I would need to delete bindings from the files. Am I right in assuming that?

I don’t use openhabian but installed Openhab with the “apt strategy”.

Thanks is advance!

Let’s start step by step as you shouldn’t (and you actually can’t) just delete bindings via linux.

  • What do you mean by “I cannot access my openhab dashboard”?
  • What does “sudo systemctl status openhab.service” say?
  • Can you access myopenhabip:9001? (it should show you the logs)
    • otherwise check the logs via tail -f /var/log/openhab/openhab.log

I am happy to provide you with the different directories but first let’s find out what your problem is, ok?

cheers
Stefan

ok! Thanks!

  1. When I say that I can’t access Openhab, I mean that when I enter the IP and then the port, Openhab does not load. If I restart Openhab and/or the Raspberry Pi, it works for maybe 2 hours until I can’t reach it again and the dashboard does not load.

openhab.service - openHAB - empowering the smart home
   Loaded: loaded (/lib/systemd/system/openhab.service; disabled; vendor preset:
   Active: active (running) since Sat 2021-06-26 11:49:24 CEST; 4h 45min ago
     Docs: https://www.openhab.org/docs/
           https://community.openhab.org
 Main PID: 2306 (java)
    Tasks: 3766 (limit: 4915)
   CGroup: /system.slice/openhab.service
           └─2306 /usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr/share/openh
Jun 26 15:10:25 raspberrypi karaf[2306]: Exception in thread "OH-thingManager-51
Jun 26 15:13:49 raspberrypi karaf[2306]: Exception in thread "OH-thingHandler-1"
Jun 26 15:21:45 raspberrypi karaf[2306]: java.lang.OutOfMemoryError: Java heap s
Jun 26 15:21:48 raspberrypi karaf[2306]: java.lang.OutOfMemoryError: Java heap s
Jun 26 15:23:49 raspberrypi karaf[2306]: java.lang.OutOfMemoryError: Java heap s
Jun 26 15:24:02 raspberrypi karaf[2306]: Exception in thread "upnp-main-878" jav
Jun 26 15:25:01 raspberrypi karaf[2306]: Exception in thread "qtp2665478-84" jav
Jun 26 15:27:59 raspberrypi karaf[2306]: Exception in thread "upnp-main-880" jav
Jun 26 15:29:28 raspberrypi karaf[2306]: Exception in thread "OH-thingHandler-6"
Jun 26 15:42:09 raspberrypi karaf[2306]: Exception in thread "OH-thingHandler-10
lines 1-20/20 (END)

As you can see, it says that Openhab is supposedly active but I am unable to access it via “Localhost” nor the usual IP that always worked.

  1. it doesn’t seem to work via the IP, however I can look at the logs via the path u said and there is a quite long error message:
2021-06-26 11:19:55.829 [ERROR] [.AbstractFaultChainInitiatorObserver] - An unexpected error occurred during error handling. No further error processing will occur.
org.apache.cxf.interceptor.Fault: Java heap space
	at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) ~[bundleFile:1.0.9]
	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) ~[bundleFile:1.0.9]
	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) ~[bundleFile:1.0.9]
	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) ~[bundleFile:1.0.9]
	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[bundleFile:1.0.9]
	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) ~[bundleFile:1.0.9]
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [bundleFile:1.0.9]
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [bundleFile:1.0.9]
	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225) [bundleFile:1.0.9]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [bundleFile:3.1.0]
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276) [bundleFile:1.0.9]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) [bundleFile:9.4.20.v20190813]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [bundleFile:?]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) [bundleFile:9.4.20.v20190813]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [bundleFile:?]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [bundleFile:9.4.20.v20190813]
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [bundleFile:?]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.Server.handle(Server.java:494) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.OutOfMemoryError: Java heap space
2021-06-26 11:20:03.480 [WARN ] [org.eclipse.jetty.server.HttpChannel] - /rest/
java.lang.OutOfMemoryError: Java heap space

I hope this helps!

Ok,

so first of all if you can start openhab and for some time it can be reached, then you should take that time to uninstall the bindings (if necessary). This is the recommended way to do so.

The logs indeed seem to point to a memory issue - however, it is very uncommon to have these issues already after 2 hours…

  1. What version are you on? you can find out by using cat /var/lib/openhab/etc/version.properties

  2. login to openhab console (you may have to restart openhab first of that fails due to the memory issue)
    openhab-cli console (use habopen as password)
    shell:info
    paste the output here (it contains the used and max heap space)

It should include something like this

Memory
  Current heap size           178,850 kbytes
  Maximum heap size           316,800 kbytes
  1. If you want to know which bundle are installed you can do
    bundle:list | grep “openHAB Add-ons :: Bundles ::”

type logout to exit the console

Sorry for the delay, I ran into some problems :slight_smile:

So: I’m running on openHAB 3.0.2

This is what the console says:

Memory
  Current heap size           90,434 kbytes
  Maximum heap size           253,440 kbytes
  Committed heap size         160,464 kbytes
  Pending objects             0
  Garbage collector           Name = 'Copy', Collections = 128, Time = 2.585 seconds
  Garbage collector           Name = 'MarkSweepCompact', Collections = 7, Time = 1.733 seconds

This is probably about 7 minutes after restarting openhab.

Cheers!

I am bit suprised about your settings. If you look at the following thread

you’ll see that the default settings are higher. You can change those in

/etc/default/openhab

i.e. the default should be like this

EXTRA_JAVA_OPTS=“-Xms250m -Xmx350m”

1 Like

Ok thanks! I’ve put it in and we’ll see how it goes. I’ll give an update on it! :smiley:

So it’s been running without problems for the past two days! Thanks a lot!

Could you maybe explain what I changed there, and what effect this had? Thanks a bunch!

sure, the settings are about how much space openhab is allowed to take. Openhab is a Java process that runs within the JVM (java virtual machine). When you start the JVM it isn’t allowed to take as much memory (RAM) as it wants but you always have to tell it what the minimum amount and the maximum amount is that it should use. So in your case it starts now with 250 (what was you limit) and is limited now around 100MB more. This is default setting which is usually fine for most OH installations in particular where the RPI limit is a 1 GB. (I am using lots of binding and have hundreds of things and items, so in my case it wasn’t enough, hence I raised it even more but I also have a 4GB RPI).

Does that answer your question? (if yes, you may want the change the title so that it reflects the content of the issue a bit better, mark the right answer as solved and put a [SOLVED] in front of the title).

cheers
Stefan

1 Like

Yup! Thanks!

1 Like