As you can see the same address is being reused.
Even if it wasn't optimized, that
would be the case too.
In the non-optimized world, the my variable would get freed at the end of the for loop (since there are no longer any references to it) and reallocated at the top. Logically, the memory manager
would find the same free block the second time around as the first since nothing changed.
While there is an optimization involved here to save some memory management work, it doesn't cause any change in the observed behaviour. What you call an optimization is just garbage collection, not an optimization at all.
Updates marked using INS and DEL elements. See chromatic's reply for details.