当GC系统没有启动时,对象是否可能被回收?
可能,看你对象分配在哪了 java中大多数对象都会存储在堆(Heap)中,但对于一些没有逃逸的小对象现在也可能分配在栈上(JVM发展历程中的一种新的优化方式).
public class TestGC03 {
public static void main(String
[] args
) {
for(int i
=0;i
<100000000;i
++) {
doMethod01();
}
}
static byte[] b2
;
static void doMethod01() {
b2
=new byte[1];
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-26602.html