title: Unit testing memory leaks
body: <p>I have an application in which a lot of memory leaks are present. For example if a open a view and close it 10 times my memory consumption rises becauses the views are not completely cleaned up. These are my memory leaks. From a testdriven perspective i would like to write a test proving my leaks and (after I fixed the leak) asserting I fixed it. That way my code won't be broken later on. So in short:</p>
  
  <p>Is there a way to assert that my code is not leaking memory from a unit test?</p>
  
  <p>e.g. Can i do something like this:</p>
  
  <pre><code>objectsThatShouldNotBeThereCount = MemAssertion.GetObjects&lt;MyView&gt;().Count;
  Assert.AreEqual(0, objectsThatShouldNotBeThereCount);
  </code></pre>
  
  <p>I am not interested in profiling. I use Ants profiler (which I like a lot) but would also like to write tests to make sure the 'leaks' don't come back</p>
  
  <p>I am using C# / Nunit but am interesed in anyone having a philosophy on this...</p>