]> git.basschouten.com Git - openhab-addons.git/commitdiff
[systeminfo] Fix heap graph too high on axis. (#11351)
authorMatthew Skinner <matt@pcmus.com>
Sat, 9 Oct 2021 08:16:23 +0000 (19:16 +1100)
committerGitHub <noreply@github.com>
Sat, 9 Oct 2021 08:16:23 +0000 (10:16 +0200)
Was calculating the “used heap” based on max heap size and not on the currently allocated size.

Signed-off-by: Matthew Skinner <matt@pcmus.com>
bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SysteminfoHandler.java

index 866967893cec02738154e077cb6e2cfcfc9527f4..05a11c5f512dd732647022562dc518eab1c4c2ca 100644 (file)
@@ -294,8 +294,8 @@ public class SysteminfoHandler extends BaseThingHandler {
                     state = new QuantityType<>(Runtime.getRuntime().freeMemory(), Units.BYTE);
                     break;
                 case CHANNEL_MEMORY_USED_HEAP_PERCENT:
-                    state = new DecimalType((Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) * 100
-                            / Runtime.getRuntime().maxMemory());
+                    state = new DecimalType((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())
+                            * 100 / Runtime.getRuntime().maxMemory());
                     break;
                 case CHANNEL_DISPLAY_INFORMATION:
                     state = systeminfo.getDisplayInformation(deviceIndex);