解决方法
最大堆大小:
Runtime.getRuntime().maxMemory();
您可能会感兴趣的其他一些计算:
Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); long totalFreeMemory = freeMemory + (maxMemory - allocatedMemory); long usedMemory = maxMemory - totalFreeMemory;