List of utility methods to do Memory Used
long | getUsedMemory() get Used Memory gc(); long totalMemory = Runtime.getRuntime().totalMemory(); gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long usedMemory = totalMemory - freeMemory; return usedMemory; |
double | getUsedMemoryInMb() get Used Memory In Mb return getTotalMemoryInMb() - getFreeMemoryInMb();
|
int | getUsedMemoryInMegabytes() get Used Memory In Megabytes long usedMemory = Runtime.getRuntime().totalMemory(); int sizeInMegaBytes = (int) (usedMemory / BYTES_IN_1_MEGABYTE); return sizeInMegaBytes; |
double | getUsedMemoryMBs() get Used Memory M Bs Runtime runtime = Runtime.getRuntime(); long memory = runtime.totalMemory() - runtime.freeMemory(); return memory / 1024.0 / 1024.0; |
int | getUsedMemoryMegaBytes() get Used Memory Mega Bytes return (int) (getUsedMemoryBytes() / 1024 / 1024); |
String | getUsedMemoryStr() get Used Memory Str long totalMem = Runtime.getRuntime().totalMemory(); long freeMem = Runtime.getRuntime().freeMemory(); return bytesToString(totalMem - freeMem); |
String | jvmInUseMemory(String size, Boolean txtByte) Obtain JVM's In Use Memory. return convertByteSize(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(), size,
txtByte);
|
long | makeUsedPhysicalMemoryData(long systemPhysicalMaxValue, long systemPhysicalFreeValue) make Used Physical Memory Data long systemPhysicalUsedValue = systemPhysicalMaxValue - systemPhysicalFreeValue; return systemPhysicalUsedValue; |
long | measureMemoryUse() Measure memory used by the VM. System.gc();
Thread.sleep(2000);
System.gc();
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
long | memoryUsed() memory Used long mem = 0; for (int i = 0; i < 10; i++) mem += memoryTotal() - memoryFree(); mem /= 10; return mem; |