Java Memory Used memoryUsed()

Here you can find the source of memoryUsed()

Description

memory Used

License

Open Source License

Declaration

public static long memoryUsed() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static Runtime runtime;

    public static long memoryUsed() {
        long mem = 0;

        for (int i = 0; i < 10; i++)
            mem += memoryTotal() - memoryFree();
        mem /= 10;/*from   w w  w .  ja  va2  s  . c om*/
        return mem;
    }

    public static long memoryTotal() {
        long mem = 0;

        for (int i = 0; i < 10; i++)
            mem += runtime.totalMemory();
        mem /= 10;
        return mem;
    }

    public static long memoryFree() {
        long mem = 0;

        for (int i = 0; i < 10; i++)
            mem += runtime.freeMemory();
        mem /= 10;
        return mem;
    }
}

Related

  1. getUsedMemoryMegaBytes()
  2. getUsedMemoryStr()
  3. jvmInUseMemory(String size, Boolean txtByte)
  4. makeUsedPhysicalMemoryData(long systemPhysicalMaxValue, long systemPhysicalFreeValue)
  5. measureMemoryUse()
  6. memoryUsed()
  7. memoryUsed()
  8. memoryUsedInMB()
  9. stringMemoryUsedInMB()