Java Memory Free hasFreeMemory(float margin)

Here you can find the source of hasFreeMemory(float margin)

Description

has Free Memory

License

Open Source License

Declaration

public static boolean hasFreeMemory(float margin) 

Method Source Code

//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();
    }
}

Related

  1. getJvmFreeMemory()
  2. getMemoryFree()
  3. getMemoryFree()
  4. getSystemFreeMemory()
  5. getTilesBasedOnFreeMemory(int rows, int cols)
  6. isFreeMemoryAvailable()
  7. jvmFreeMemory(String size, Boolean txtByte)
  8. memoryFree()
  9. memoryFree()