Java Memory Used getUsedMemory()

Here you can find the source of getUsedMemory()

Description

Return the number of memory bytes used, which is computed by subtracting the 'free' memory from 'total' memory.

License

Open Source License

Return

number of bytes of memory used

Declaration

public static long getUsedMemory() 

Method Source Code

//package com.java2s;
// Refer to LICENSE for terms and conditions of use.

public class Main {
    /**//from   w  w  w.java2  s  .  c om
     * Return the number of memory bytes used, which is computed by subtracting
     * the 'free' memory from 'total' memory.
     *
     * @return number of bytes of memory used
     */
    public static long getUsedMemory() {
        long total = Runtime.getRuntime().totalMemory();
        long free = Runtime.getRuntime().freeMemory();
        return total - free;
    }
}

Related

  1. getUsedMemory()
  2. getUsedMemory()
  3. getUsedMemory()
  4. getUsedMemory()
  5. getUsedMemory()
  6. getUsedMemory()
  7. getUsedMemoryInMb()
  8. getUsedMemoryInMegabytes()
  9. getUsedMemoryMBs()