This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I don't even want to think about how long it must have taken to write that out in ASCII. But I hope everyone preparing for the exam will take note how much an effective diagram like this simplifies a complicated GC problem. There's really no better way to tackle it.
First, gb2.g.g should point to the rectangular object (not the object that holds it (it being gb2.g.g)) -- same with gb1.g.g:
Then after "line 10" is executed, the diagram should look like this:
Now, there is no access to GB(2) and GB(3) from any of the main references, gb1 and gb2 (however, there is a reverse reachability available from GB(3) to GB(2), then to gb1 which doesn't count), so they become eligible for GC.