Will the member variables inside the java outer object be reclaimed by the garbage collector after the outer object is left empty?

public class Person{
    public Man m;
}

Person p = new Person();
Man man=new Man();
p.m = man;

//do other things

p = null;

System.gc();

when p=null is set, will the object m be recycled with p the next time gc?

Sep.03,2021

you need to determine whether there are other strong references in man. Gc will only drop when the root object cannot be found


if there are no other references from the root node to m, then it will

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-1e60a5e-5a915.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-1e60a5e-5a915.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?