private static long getSizeOfFreeMemory ( ) { float fractionToUse = GlobalConfiguration . getFloat ( ConfigConstants . TASK_MANAGER_MEMORY_FRACTION_KEY , ConfigConstants . DEFAULT_MEMORY_MANAGER_MEMORY_FRACTION ) ; Runtime r = Runtime . getRuntime ( ) ; long max = r . maxMemory ( ) ; long total = r . totalMemory ( ) ; long free = r . freeMemory ( ) ; long available = max - total + free ; return ( long ) ( fractionToUse * available ) ; }
Returns the size of free memory in bytes available to the JVM .