/** * @return the amount of memory currently being used, in bytes. Often inaccurate, but there's no better thing to do from within * the JVM. */ public static long getUsedMemory() { gc(); long totalMemory = Runtime.getRuntime().totalMemory(); gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long usedMemory = totalMemory - freeMemory; return usedMemory; }
/** * @return the amount of memory currently being used, in bytes. Often inaccurate, but there's no better thing to do from within * the JVM. */ public static long getUsedMemory() { gc(); long totalMemory = Runtime.getRuntime().totalMemory(); gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long usedMemory = totalMemory - freeMemory; return usedMemory; }
/** * @return the amount of memory currently being used, in bytes. Often inaccurate, but there's no better thing to do from within * the JVM. */ public static long getUsedMemory() { gc(); long totalMemory = Runtime.getRuntime().totalMemory(); gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long usedMemory = totalMemory - freeMemory; return usedMemory; }