Java Memory Usage getMemoryFootprint()

Here you can find the source of getMemoryFootprint()

Description

get Memory Footprint

License

Apache License

Declaration

public static String getMemoryFootprint() 

Method Source Code

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

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    private static final NumberFormat MEM_FMT = new DecimalFormat(
            "##,###.##");

    public static String getMemoryFootprint() {
        Runtime runtime = Runtime.getRuntime();
        String memoryInfo = "Memory - free:"
                + kbString(runtime.freeMemory()) + " - max:"
                + kbString(runtime.maxMemory()) + " - total:"
                + kbString(runtime.totalMemory());
        return memoryInfo;
    }//w ww . ja  v  a2 s .  c  o  m

    public static String kbString(long memBytes) {
        return MEM_FMT.format(memBytes / 1024) + " kb";
    }
}

Related

  1. describeMemoryUsage()
  2. estimateMemoryUsage(String s)
  3. getMemberName(int number)
  4. getMemInfo()
  5. getMemoryInfo()
  6. getMemoryInfo()
  7. getMemoryInfo()
  8. getMemorySize(long size)