title: Should I ever manually force garbage collection in my WPF app?
body: <p>I've just been sorting out some memory leaks in my WPF application. To do so, I used the CLR profiler, as well as watching process statistics in Windows Task Manager. My basic test was to make sure that when a certain window was closed, it didn't still hang around in memory.</p>
  
  <p>I'm slightly new to windows development, and at first I was getting confused because in a simple test application, it seemed as if no matter what, my windows were always staying in memory after being closed. But I eventually worked out that this did not mean there was a memory leak, but just simply that they hadn't been garbage collected yet. So I had to create a button in my main window hooked up to an event handler that contained code to manually force garbage collection. By manually garbage collecting, I could then complete my memory leak tests, and I got it all sorted.</p>
  
  <p>But it got me thinking - <strong>is there ever a need to manually force garbage collection?</strong></p>
  
  <p>It pains me to watch my application's memory consumption go up and up as I open and close windows. Of course, eventually, garbage collection automatically runs and it all gets sorted out. But it almost seems like a good idea to manually garbage collect after these heavy windows get closed. But is there any point? I get the feeling that testing aside, we are not supposed to force garbage collection - just let the system sort it out.</p>
  
  <p>Thoughts appreciated.</p>