Here you can find the source of hasFreeMemory(float margin)
public static boolean hasFreeMemory(float margin)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt public class Main { private static final Runtime S_RUNTIME = Runtime.getRuntime(); public static boolean hasFreeMemory(float margin) { return usedMemory() < (1f - margin) * ((float) maxMemory()); }// w w w . j a va2 s. c om public static long usedMemory() { return S_RUNTIME.totalMemory() - S_RUNTIME.freeMemory(); } public static long maxMemory() { return S_RUNTIME.maxMemory(); } public static long totalMemory() { return S_RUNTIME.totalMemory(); } public static long freeMemory() { return S_RUNTIME.freeMemory(); } }