Do I need to add IDisposable to all these poco classes so they are removed right away?
Anything that implements IDisposable
should have IDisposable.Dispose()
called as soon as the object is no longer needed. Typically the best way do accomplish that is with a using
statement.
IDisposable
is there to allow for expensive resources (think DB connections) and/or unmanaged resources (think a COM handle) to be released as soon as the object no longer needs access to them. Calling IDisposable.Dispose()
will release those resources, but will not cause the managed object to be garbage collected any sooner.
My question is how do I make my memory footprint disappear
The .NET runtime will garbage collect when it things it is the appropriate time to do so. Although you can force garbage collection, the runtime will almost always make a better decision on timing than you would.
What might cause the Garbage Collector to be unable to release memory?
If you still have a reference to the objects somewhere, they will not be garbage collected. You can use the memory profiler in Visual Studio to see what is still referenced (therefore uncollectable) after your schedule job runs.
Should you be worried?
Probably not. Even though the .NET Runtime may allocate significant memory, it will usually release it in a very efficient manner if the memory pressure on the system so warrants. Just be sure you are not holding object references longer than needed.