Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static long getMaxMemory() { long memory = Runtime.getRuntime().maxMemory() / (1024 * 1024 * 1024); if (memory < 1) { memory = Runtime.getRuntime().maxMemory() / (1024 * 1024); } return memory; } }