Since there is a reference to the objects referenced by the images b1 and b2 due to the underlying lines.
a1.b1 = b1 ; a1.b2 = b1 ; a2.b2 = b2 ;
Let's pretend that:
b1--->BetaObj1 b2---BetaObj2 a1---> AlphaObj1 a2---> AlphaObj2
a1.b1 points to b1, which means that there is a link to BetaObj1 a1.b2 points to b1, which means there is another link to BetaObj1
(There are 3 links to BetaObj1 at this moment)
a2.b2 points to b2, which means there is a link to BetaOBj2
(There are 2 links to BetaObj2 at this moment)
a1=null; makes AlphaObj1 suitable for GC
b1=null; makes the reference counter BetaObj1 equal to 2, so this object is not suitable for GC
b2=null; makes the reference counter BetaObj2 equal to 1, so this object is not suitable for GC.
source share