posted 18 years ago
If you're asking "how will we know if an object is eliminated by the garbage collector", the answer is, quite frankly, that you won't. Garbage collectors work like this:
1) Unmark all resources
2) Check every variable in use
3) If a variable points to object x, mark it
4) Delete all unmarked resources
5) Reorganize data to eliminate memory fragmentation
In short, in order to determine whether object x has been deleted, you'd need a reference to object x. If any reference to object x exists, the garbage collector leaves it alone. It makes a paradox.
You'll just have to trust that at some point it will be deleted. That's one drawback to GC.