Memory leak

I recently installed the network health binding and I’ve detected that openhab is leaking memory (see graphs below). Is there a way to inspect memory usage by objects in rules?


(drops correspond to openhab service restart)

my bindings:

org.openhab.action.astro-1.8.0.jar
org.openhab.action.mail-1.8.0.jar
org.openhab.action.pushover-1.8.0.jar
org.openhab.binding.asterisk-1.8.0.jar
org.openhab.binding.astro-1.8.0.jar
org.openhab.binding.exec-1.8.0.jar
org.openhab.binding.http-1.8.0.jar
org.openhab.binding.hue-1.8.0.jar
org.openhab.binding.mochadx10-1.8.0.jar
org.openhab.binding.mqtt-1.8.0.jar
org.openhab.binding.netatmo-1.8.0.jar
org.openhab.binding.networkhealth-1.8.0.jar
org.openhab.binding.ntp-1.8.0.jar
org.openhab.binding.rfxcom-1.8.0.jar
org.openhab.binding.samsungtv-1.8.0.jar
org.openhab.binding.systeminfo-1.8.0.jar
org.openhab.binding.weather-1.8.0.jar
org.openhab.binding.zwave-1.9.0-SNAPSHOT.jar
org.openhab.io.habmin-1.7.0-SNAPSHOT.jar*
org.openhab.io.myopenhab-1.8.0.jar
org.openhab.persistence.db4o-1.8.0.jar*
org.openhab.persistence.exec-1.8.0.jar
org.openhab.persistence.logging-1.8.0.jar
org.openhab.persistence.rrd4j-1.8.0.jar

NB: I don’t know if this problem is new for me

This might be normal behavior for Java. The way Java works is usually it has a maximum memory size and if it is not close to that max it is kind of lazy about garbage collection so the memory usage will tend to grow until the max is approached. This is particularly true with long running server applications like OH.

Another thing that could be happening is once a Java application acquires memory it never gives it back to the OS so the size of a Java program in RAM can only every grow.

Or there could be a memory leak. :wink: It is notoriously difficult to find memory leaks in Java unfortunately and it could be coming from core or any of those bindings.

My current instance of OH which has been running around a week without a restart is sitting at 3.6 Gb virtual memory but only 346 Mb of physical memory. I can’t say how it has grown to that over time, whether this is unusual, and how quickly it grew to that.

I’d love to hear what one of the developers or someone who has hooked up a profiler to OH might have to say on the matter.

NOTE: My info on the behavior of Java comes from at least five years ago Java EE applications running on things like Tomcat, JBoss and Weblogic. It may not work like this anymore. Also, the JVM also provides a number of features to fine tune the above behavior which I have not looked to see what, if any, OH is using. In other words, my conjecture could be bunk.

1 Like

I can confirm this.
I had openhab 2.0.0 running since relase and installed Network Health binding yesterday. Same problem here, have tried to just adding two devices and slowed it really down with refreshrate of 60000ms, but still it seems to be a memory leak.

Did anyone verify whether this is in fact a Network monitor binding issue?
I am slowly depleting my memory - gets worse when I have network outages.
Is there a workaround?

Did I mention I am seeing this in 2.3.0 ?
Anyone?