I have an ImageList
that is populated with, well you guessed it, images.
These images are loaded into memory in a dataset as a Bitmap
. Until I loaded them into the ImageList
the rise of memory is not worry. But when they are added to the ImageList
the memory usage sky rockets.
But the biggest problem is when I have to reload the list of images. I've tried to call dispose on every image on the list but the memory is not freed.
This is the code I tried to clean up the memory:
foreach (Image item in imageList.Images)
{
item.Dispose();
}
imageList.Images.Clear();
GC.Collect();
What am I doing wrong?