Add JvmInformation#getMemoryUsed method

This commit is contained in:
JeremyStar™ 2024-07-11 05:31:11 +02:00
parent d3b09848b6
commit 7d8d277bc1
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -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.
* <p>
* 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.
*