c# - How to test if an object is disposed and GC'ed? -


i'm writing code delete object , wanted have unit test ensure object deleted. best way this? if gc work should not holding references how can test without reference?

there no way test if object disposed in general case.

weakreference thing looking for. can create weakreference part of test , after code has run this:

weakreference wr = new weakreference(obj); gc.collect(); assert.istrue(!wr.isalive); 

Comments

Popular posts from this blog

.htaccess - htaccess convert request to clean url and add slash at the end of the url -

php - facebook and github login HWIOAuthBundle and FOSUserBundle in Symfony2.1 -

hadoop - Sqoop installation export and import from postgresql -