code is as follows:
package referenceCoutingGC;
/**
*
* testGC()ogjAogjBGC
*
*/
public class referenceCoutingGC {
public Object instance = null;
private static final int _1MB = 1024*1024;
private byte[] bigSize = new byte[2*_1MB];
public static void testGC(){
referenceCoutingGC objA = new referenceCoutingGC();
referenceCoutingGC objB = new referenceCoutingGC();
objA.instance = objB;
objB.instance = objA;
objA = null;
objB = null;
//GCobjAobjB?
System.gc();
System.out.println("");
}
public static void main(String[] args){
testGC();
}
}
there are output results in the book. The words 4603k-> 210k are also specifically stated.
mine is jdk 1.8