Every time your code calls
"new ..." write the reference variable name outside the heap, draw the object created (a square for instance) inside the heap, and link up both elements with an arrow. When a reference variable changes, write a new arrow from this reference variable to the new target, and CROSS OFF the original reference variable arrow. At the time to call
System.gc(), those objects crossed off are unreachable (unaccessible from a live
thread) and so eligible for garbage collection. Be care with more complex objects which might contain inner references to either other references or new objects. The key point is draw arrows from references to their respective objects and removes (crossing off) when references changes.
I hope this helps.