From f888e5cd1c4511099328a32220b5169d5b494494 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 6 Sep 2022 13:09:28 +0200 Subject: [PATCH] [Fix] Properly show memory usage --- .../java/li/strolch/utils/helper/SystemHelper.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/li.strolch.utils/src/main/java/li/strolch/utils/helper/SystemHelper.java b/li.strolch.utils/src/main/java/li/strolch/utils/helper/SystemHelper.java index da92640ec..07c61530c 100644 --- a/li.strolch.utils/src/main/java/li/strolch/utils/helper/SystemHelper.java +++ b/li.strolch.utils/src/main/java/li/strolch/utils/helper/SystemHelper.java @@ -96,21 +96,27 @@ public class SystemHelper { return FileHelper.humanizeFileSize(Runtime.getRuntime().maxMemory()); } - public static String getUsedMemory() { + public static String getTotalMemory() { return FileHelper.humanizeFileSize(Runtime.getRuntime().totalMemory()); } + public static String getUsedMemory() { + return FileHelper.humanizeFileSize(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); + } + public static String getFreeMemory() { return FileHelper.humanizeFileSize(Runtime.getRuntime().freeMemory()); } public static String getMemorySummary() { StringBuilder sb = new StringBuilder(); - sb.append("Memory available "); //$NON-NLS-1$ + sb.append("System Memory available "); //$NON-NLS-1$ sb.append(SystemHelper.getMaxMemory()); - sb.append(" / Used: "); //$NON-NLS-1$ + sb.append(", Total: "); //$NON-NLS-1$ + sb.append(SystemHelper.getTotalMemory()); + sb.append(", Used: "); //$NON-NLS-1$ sb.append(SystemHelper.getUsedMemory()); - sb.append(" / Free: "); //$NON-NLS-1$ + sb.append(", Free: "); //$NON-NLS-1$ sb.append(SystemHelper.getFreeMemory()); return sb.toString(); }