25,980
社区成员




public class Test2 {
public static void main(String[] args) {
for(int i=0;i<100000;i++){
Test2 test = new Test2();
test = null;
}
//System.gc();
System.out.println("this is GC test!");
}
}
>javac Test2.java
>java -verbosegc Test2
[GC 512K->135K(1984K), 0.0021429 secs]
this is GC test!
时间是0.0021429(千万别小看这0.0000047)
public class Test2 {
public static void main(String[] args) {
for(int i=0;i<100000;i++){
Test2 test = new Test2();
//test = null;
}
//System.gc();
System.out.println("this is GC test!");
}
}
>javac Test2.java
>java -verbosegc Test2
[GC 512K->135K(1984K), 0.0021476 secs]
this is GC test!
时间是0.0021476