Java tutorial
//package com.java2s; public class Main { public static int calculateMaxCacheSize() { return (int) Math.min(Runtime.getRuntime().maxMemory() / 32L, 0x7fffffffL); } }