Java Memory Usage getMemoryStatus()

Here you can find the source of getMemoryStatus()

Description

get Memory Status

License

Apache License

Declaration

public static String getMemoryStatus() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.NumberFormat;

public class Main {
    public static String getMemoryStatus() {
        Runtime rt = Runtime.getRuntime();
        NumberFormat nf = NumberFormat.getInstance();
        nf.setGroupingUsed(true);//  w  ww  .  j a  v  a  2 s. c  o m
        nf.setMinimumFractionDigits(0);
        long total_mem = rt.totalMemory();
        long free_mem = rt.freeMemory();
        long used_mem = total_mem - free_mem;
        return "Amount of used memory/free memory: "
                + nf.format(used_mem / 1000) + "KB / "
                + nf.format(free_mem / 1000) + " KB";

    }
}

Related

  1. getMemoryFootprint()
  2. getMemoryInfo()
  3. getMemoryInfo()
  4. getMemoryInfo()
  5. getMemorySize(long size)
  6. getMemoryUsage()
  7. getMemoryUsage()
  8. getMemoryUsage()
  9. getMemoryUsage()