Java tutorial
//package com.java2s; public class Main { private static final Runtime RUNTIME = Runtime.getRuntime(); static int getMaximumMemory() { long maxMem = RUNTIME.maxMemory(); if (maxMem > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) maxMem; } }