MQTT publish message dropped; openHAB memory use slowly increasing

I’m using openHAB with the MQTT binding to monitor seven water meters using ESP8266 devices flashed with Tasmota. The MQTT Broker is Mosquitto version 1.5.7 running on the same server as openHAB. Each ESP8266 reports a counter value via MQTT every minute. It was working fine until after a bit over two weeks four of them didn’t show any data in openHAB. The logs showed “MQTT QoS 0 publish message dropped” every minute for the four of them, while the other three were running fine. At this point the memory usage of openHAB was at 21.4%. Memory usage of mosquitto is about 0.1%. After restarting openHAB, everything worked fine again and the memory usage had dropped till 16.1%. I notice that the memory usage is slowly increasing now and I am afraid at some point the same problem will appear.

There are some other Things in this openHAB system, but I am almost certain the problem is with these water meters, as I had no other issues before and it was running for months. I use some rules to calculate the flow and one of them will trigger an alarm (running a command to send an SMS via the Exec Binding). Here are the rules (only displaying for water meter 1 and 2, the rest are the same as 2) as stored in a file called watermeter.rules.

var Number interval = 1 // measuring interval in min.
var Number timeBack = 10 // time to look back in min.
var Number avgThreshold = 15 // threshold in liter/min. 
var Number oldCounter1 = 0
var Number warned1 = 0
var Number oldCounter2 = 0
var Number oldCounter3 = 0
var Number oldCounter4 = 0
var Number oldCounter5 = 0
var Number oldCounter6 = 0
var Number oldCounter7 = 0

rule "Watermeter1 debiet en alarm"
        Item Watermeter1_Pulsecounter received update
        var Number diff = ((Watermeter1_Pulsecounter.state as Number) - oldCounter1)/(interval*10)  // waterflow in liter/min.
        if (diff < 0) diff = 0
        if (((delta1.averageSince(now.minusMinutes(timeBack)) as Number) > avgThreshold) && (oldCounter1 != 0) && (warned1 == 0)) {
                warned1 = 1 // make sure to only warn once
                logWarn("watermeter", "De kraan van watermeter 1 staat open!")
        } else if (((delta1.averageSince(now.minusMinutes(timeBack)) as Number) < avgThreshold) && (warned1 == 1)) {
                warned1 = 0  // if it happens again, we should warn again
	oldCounter1 = (Watermeter1_Pulsecounter.state as Number)

rule "Watermeter2 debiet"
        Item Watermeter2_Pulsecounter received update
        var Number diff = ((Watermeter2_Pulsecounter.state as Number) - oldCounter2)/(interval*10)  // waterflow in liter/min.
        if (diff < 0) diff = 0
        oldCounter2 = (Watermeter2_Pulsecounter.state as Number)

The ‘delta’ Items are saved with the rr4dj persistence with strategy = everyUpdate, everyMinute, restoreOnStartup.

Does anyone know whether this increase in memory usage might be the cause of the problem and how to solve it? Thanks in advance.

  • Platform information:
    • Hardware: Intel Atom D2550, x86_64, 4 CPUs, 4GB RAM
    • OS: Linux Debian 4.19.67-2+deb10u2
    • Java Runtime Environment: openjdk 11.0.12
    • openHAB version: 3.2.0