Java Memory Usage getMemoryUsage()

Here you can find the source of getMemoryUsage()

Description

get Memory Usage

License

Open Source License

Declaration

public static String getMemoryUsage() 

Method Source Code

//package com.java2s;

public class Main {
    public static String getMemoryUsage() {
        Runtime rt = Runtime.getRuntime();
        long total = rt.totalMemory() / (1024 * 1024);
        long free = rt.freeMemory() / (1024 * 1024);
        return String.format("Used: %d MB, Free: %d MB, Total: %d MB", total - free, free, total);
    }/*from  w  w  w .j  av a 2  s .  co  m*/
}

Related

  1. getMemoryStatus()
  2. getMemoryUsage()
  3. getMemoryUsage()
  4. getMemoryUsage()
  5. getMemoryUsage()
  6. getMemoryUsage()
  7. getMemoryUsage()
  8. getMemoryUsage()
  9. getMemoryUsage()