From 7d8d277bc13addeb72b1b585bc5d1cd0c03cff42 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Thu, 11 Jul 2024 05:31:11 +0200 Subject: [PATCH] Add JvmInformation#getMemoryUsed method --- .../sosengine/base/data/info/JvmInformation.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java b/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java index d5be7994..527b354e 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java +++ b/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java @@ -120,7 +120,7 @@ public final class JvmInformation { } /** - * Returns the total amount of memory used by the JVM and the running application. + * Returns the total amount of memory used the running application AND JVM. *

* Note: This is an estimate. * @@ -151,6 +151,16 @@ public final class JvmInformation { return Runtime.getRuntime().freeMemory(); } + /** + * Returns the amount of memory used by the running application. + * + * @return amount of used memory + * @since 1-alpha1 + */ + public static long getMemoryUsed() { + return getMemoryMax() - getMemoryFree(); + } + /** * Returns the memory usage of the heap. *