The o object on line 5 is a local variable for the doSomething()
method.
He will become an orphan after line 8.
Since both local and global links will no longer reference the object.
Edit:
Although it is very late, but I hope that someday it can help someone.
You can get such events by using a library I'm developing called gcRadar . It provides events when the object is orphaned and after the actual garbage collection of the object.
Any suggestions for improvement in the library are welcome.
source share