Here you can find the source of allocatedMemory()
public static long allocatedMemory()
//package com.java2s; public class Main { static Runtime runtime = Runtime.getRuntime(); public static long allocatedMemory() { return runtime.totalMemory() - runtime.freeMemory(); }//from w w w . j a v a2 s. c o m public static long totalMemory() { return runtime.totalMemory(); } public static long freeMemory() { return runtime.freeMemory(); } }