Here you can find the source of getMemoryStatus()
public static String getMemoryStatus()
//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"; } }