Memoryleak during rule execution?

  • Platform information:
    • Hardware: AMD Ryzen 9 3900X / 64GB / 1TB NVME
    • OS: Windows 10
    • Java Runtime Environment: 8.0.2510.8
    • openHAB version: 2.5.9
  • Issue of the topic:
    Hello everybody,

I’m kind of new to Openhab and have an issue regarding memory usage. I’ve created a rule to do a full color fade for 3 of my WiFi LED Binding using LED controller. When turned off it is supposed to stop the timer and send off commands to the switches of the 3 LED controllers.

What worries me now is that during the execution of the rule the memory used by the Java™ Platform SE binary is constantly increasing. About 2-4mb / second. I’ll post my rule below this text because I just cannot find my error.

When i stop the execution of the rule (Turn the Switch Oben_Fading to OFF) the memory increase stops at once.

Maybe anybody of you can help me here? Thank you in advance.

Best regards,

    var Timer timer = null
    var HSBType hsb = null
    var HSBType newHsb = null
    var DecimalType color = null

    rule "Start Wabe 3 Rechts fading"
      Item Oben_Fading changed
      if (Oben_Fading.state == ON) {
        // set a timer to sligtly change the color again and again
        timer = createTimer(now, [|
          if (Wabe3Links_Eingeschaltet.state == OFF) {
          if (Wabe3Links_Eingeschaltet.state == OFF) {
          if (Wabe3STREAM_Eingeschaltet.state == OFF) {
          if (timer !== null) {
      else {
        timer = null

    rule "Wabe 3 Rechts Fade Next"
        Item Oben_Fade_Next changed
        if (Oben_Fading.state == ON) {
          // get your current color
          hsb = Wabe3Links_Color.state as HSBType

          // change it a little bit
          color = new DecimalType(hsb.hue.intValue % 359 + 1) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)

          newHsb = new HSBType(color,new PercentType(100),new PercentType(100))

          // set the new color    

If you are not running out of memory it’s probably not a problem. I’ve not heard of any reports of memory leaks in rules and it’s been over a year since there was a change to the Rules DSL rules engine. If there were I problem I would expect to have seen if before now.

There is nothing that jumps out as unusual in the rules except for that sleep which is a bit long and should probably be a timer instead.

There is nothing wrong with the current approach, but I would have expected the fade next rule’s code to just be inside the Timer instead of creating a new Item and rule to handle it.

1 Like