Here you can find the source of getJVMMemoryMB()
public static long getJVMMemoryMB()
//package com.java2s; public class Main { private final static long mb = 1024 * 1024; public static long getJVMMemoryMB() { return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / mb; }//from w w w .ja v a 2s. c o m }