In-depth understanding of the second version of the java virtual machine code listing 3-1 has no output for the validation of the reference algorithm, which is not consistent with the instructions in the book. why?

The

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

Mar.16,2021

his output is because the run parameter is added when running java, which should be -XX:+PrintGCDetails .
personal understanding, this section is just a brief introduction, and this example is just to tell you which two objects will be recycled, you can ignore these logs for the time being, and if you are interested in reading this chapter, you can look back on these examples.
to put it bluntly, even if you can let the program output these GC logs, you may not be able to understand them. So, read on.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf5507-31f5b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf5507-31f5b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?