So what does the doComplexStuff method do? Does it create or assign any X instances? Or is it (as I think) a red herring having no effect on the number of instances?
I suggest you write out the code, and also write out the names of all the references, x, x2 etc. Then draw little squares each representing an instance; at the end of line 8, how many little squares have you got? How many objects have you got at the end of line 6, and how many are then eligible for GC?