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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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