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

I'm writing some code to delete an object and wanted to have a unit test to ensure that the object is always deleted. What is the best way to do this? If GC is to work you should not be holding any references so how can you test without a reference?


There is no way to test if object is disposed in general case.

WeakReference is probably the thing you are looking for. You can create a WeakReference as part of the test and after your code has run this:

WeakReference wr = new WeakReference(obj);

Need Your Help

Boost Intrusive unordered_set broken in 1.48 with GCC in C++11 mode

c++ gcc boost c++11 intrusive-containers

Boost Intrusive's unordered_set is broken if you do a vanilla install of Fedora 17 which comes with GCC 4.7 and Boost 1.48, and use C++11 mode. On Fedora 16, which comes with GCC 4.6.2 and Boost 1...

Convert snmp octet string to human readable date format

python decode snmp pysnmp

Using the pysnmp framework i get some values doing a snmp walk. Unfortunately for the oid