Java Memory memory()

Here you can find the source of memory()

Description

return used memory

License

Open Source License

Declaration


public static long memory() 

Method Source Code

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

public class Main {
    /**//from  www  . ja  v  a 2s  .c  o  m
     * return used memory
     * @return
     */

    public static long memory() {
        long m = Runtime.getRuntime().totalMemory()
                - Runtime.getRuntime().freeMemory();
        return m;
    }

    public static float memory(String format) {

        if (format.equals("mb")) {
            long m = memory();
            return (float) (m / 1024.0 / 1024.0);
        } else {
            return (float) memory();
        }
    }
}

Related

  1. logMemoryStats(String msg)
  2. makeVmMemoryDivisibleBy4(long memory)
  3. measureMemoryBefore()
  4. memory()
  5. memory()
  6. memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length)
  7. memoryInfo()
  8. memoryIsLow()
  9. memoryOccupied()