I have this "Linked Web"(?) data structure ie. each object has a bunch of references to other objects.
So i wrote a method that is supposed to 'remove' a passed object by removing all references to it.
I need to test it and make sure that after i run the method the particular object i want to remove is not referenced by anything else
How could I do this?
An idea would be to force a Garbage Collection then run my delete object method and then force another GC to see if it found an object.
if it found an object for deletion then I would assume that my method works but if it found nothing to collect then I would assume that something is referencing it and would have to plug that leak
Is this possible? How?
Thanks, Ryan
You can keep track of each object via a WeakReference and check the IsAlive property after a garbage collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With