堆
作者:互联网
虚拟机总内存占用电脑总内存的1/4;初始化内存占用电脑总内存的1/64,
public class MemoryTest { public static void main(String[] args) { long maxMemory = Runtime.getRuntime().maxMemory(); long totalMemory = Runtime.getRuntime().totalMemory(); System.out.println((maxMemory/(double)1024/1024)+"M;"+(totalMemory/(double)1024/1024)); System.out.println("最大内存占用总内存的1/4"+Math.round(15.3/(maxMemory/(double)1024/1024/1024)));//虚拟机总内存占电脑总内存的1/4 System.out.println("236*16 约等于 3492"+ (236*16/1024/1024)); //初始化内存占用最大内存的1/16,占用电脑总内存的1/64 } }
标签:,1024,maxMemory,totalMemory,System,内存,占用 来源: https://www.cnblogs.com/jzbl/p/16336389.html