所有的线程共享Java堆,在这里还可以划分线程私有的缓冲区(Thread Local Allocation Buffer,TLAB)
public class Test {public static void main(String[] args) {System.out.println("start ...");try {TimeUnit.SECONDS.sleep(1000000);} catch (Exception e) {e.printStackTrace();}System.out.println("...end");}
}
调个参数 -Xms10m -Xmx10m 启动
然后启动 jvisualvm.exe
《Java虚拟机规范》中对Java堆的描述是:所有的对象实例以及数组都应当运行时分配在堆上。(The heap is the run-time data area from which memory for all class instance and arrays is allocated) “几乎”所有的对象实例都在这里分配内存–从实际使用角度看