Here you can find the source of getAllocatedMemory()
public static int getAllocatedMemory()
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w . jav a2s . c om*/ * Returns the allocated amount of memory (in MB) this JVM is using. * * @return allocated memory */ public static int getAllocatedMemory() { return Math.round((float) (Runtime.getRuntime().totalMemory() / 1048576L)); } }