List of utility methods to do Memory Information
long | getMemoryIncrease() Will calculate the increase in memory compared to the moment of the most recent startMeasurement() call. if (before == null || after == null) { throw new IllegalStateException( "You must call startMeasurement() at least once before calling this method"); hardClean(); after = getMemoryUsage(); long diff = after - before; return (diff); ... |
String | getMemoryInfo() get Memory Info return Runtime.getRuntime().totalMemory() / 1024L / 1024L + "M/" + Runtime.getRuntime().maxMemory() / 1024L / 1024L + "M"; |
long | getMemoryLimit() Get maximum memory which can be allocated by jvm. return Runtime.getRuntime().maxMemory();
|
int | getMemoryLimitMinSize() get Memory Limit Min Size return memoryLimitMinSize.intValue();
|
String | getMemoryStats() get Memory Stats Runtime r = Runtime.getRuntime(); System.gc(); int MB = 1024 * 1024; return r.freeMemory() / MB + " MB free, " + (r.totalMemory() / MB - r.freeMemory() / MB) + " MB used, " + r.maxMemory() / MB + " MB max, " + r.totalMemory() / MB + " MB total"; |
int | getMemoryStats(int mode) Returns the desired information about the game's memory switch (mode) { case TOTAL_MEMORY: return (int) (runtime.totalMemory() / 1024 / 1024); case USED_MEMORY: return (int) ((runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024); case FREE_MEMORY: return (int) (runtime.freeMemory() / 1024 / 1024); return 0; |
String | getMemoryStatus(boolean preRunGarbageCollector) get Memory Status getRuntimeAndRunGC(preRunGarbageCollector); return "# Memory(MB): Total=" + getTotalMemory(false) + ", Used=" + getConsumedMemory(false) + ", Free=" + getFreeMemory(false); |
String | getMemoryString() Gets a String containing info of available and used memory of this JVM. return "Mem Total in JVM: " + (Runtime.getRuntime().totalMemory() / FACTOR_MB) + " Free in JVM: " + (Runtime.getRuntime().freeMemory() / FACTOR_MB) + " Max Limit: " + (Runtime.getRuntime().maxMemory() / FACTOR_MB); |
String | getMemoryString() get Memory String Runtime rt = Runtime.getRuntime(); long free = rt.freeMemory(); long total = rt.totalMemory(); long max = rt.maxMemory(); long used = total - free; long percent1 = used * 100L / total; long percent2 = used * 100L / max; return "Working memory: " + percent1 + "% (" + used + "/" + total + ")" + " VM Max: " + percent2 + "% (" ... |
float | getMemoryUtilizationPercent() Get the amount of memory used by the current JVM as a percentage of the maximum amount of memory it is allowed to use (via the -Xmx parameter)
final Runtime rt = Runtime.getRuntime(); final float usedMemory = rt.totalMemory() - rt.freeMemory(); return usedMemory / rt.maxMemory(); |