private static double getFreeMemoryPercentage() { Runtime rt = Runtime.getRuntime(); long free = rt.freeMemory(); long total = rt.totalMemory(); long max = rt.maxMemory(); return (max - total + free) / (max + 0.0); }