I said that showing exception stack along would be not informative, but actually, after looking at it I got a clear idea what, most likely, is missing. Thank you.
Please look thoroughly at the declaration of the class
System.Drawing.Image
:
http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx[
^].
Please, pay special attention for this: it implements the interface
System.IDisposable
:
http://msdn.microsoft.com/en-us/library/system.idisposable.aspx[
^].
It means that you need to guarantee that
IDisposable.Dispose()
is always called before you loose the access to each and every instance of the image. Garbage Collector cannot completely dispose the object of the types implementing this interface. Most typical reason is that such object use unmanaged resources. Roughly speaking, your unmanaged resources you use leaks out.
This is not the only possible reason for memory leaks. I suspected your images due to the fact that you reported that handles are collected. This is quite a syndrome.
There are other possible reasons for memory leaks. First of all, please read on the principles of Garbage Collection:
http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29[
^].
I explained how, despite of the automated garbage collection, you still could allow some leaks, in my past answers:
Best way to get rid of a public static List Causing an Out of Memory[
^],
Memory management in MDI forms[
^],
Memory leak in WPF DataBinding[
^],
deferring varirable inside the loop can cuase memory leak?[
^],
Garbage collectotion takes care of all the memory management[
^].
—SA