Hello,
I have a question, what is the right/best way to free the memory. In my case, the method which I have wrote, is running in a thread and receives Bitmaps from the camera. These Bitmaps are shown in a pictuebox. So if the picturebox currently shows the bitmap it is not possible to dispose this bitmap and the reserved memory by the programm is growing all the time.
Any ideas?
(Visual Studio C# 2010 Express)
Loading
Archie FlinkPosted Jun 21, 2011, 7:08 AM
Pradeep ChandrakerPosted Jun 20, 2011, 10:42 PM
FroglegPosted Jun 20, 2011, 2:51 PM
Archie FlinkPosted Jun 20, 2011, 7:46 AM
I have wondered when i found a big difference between :
bmp.SetPixel(x, y, Color.FromArgb(bCol, bCol, bCol)); // no mem growing
and
bmp.SetPixel(x, y, colorList[bCol]); // continuously mem growing
bCol range is 0 - 255. colorList is a list of assigned colors for each grayscale value, will be generated once while FormLoad.
List
public void get_color_list()
{
Bitmap im1 = new Bitmap("C:\\ims_data\\Temp\\pal.png");
Bitmap bmp= new Bitmap(im1, 55, 255);
for (int j = 0; j < bmp.Height; j++)
{
Color pixelColor = bmp.GetPixel(0, j);
colorList.Insert(j, pixelColor);
}
im1.Dispose();
bmp.Dispose();
}
What could be wrong if I just refer to the color in a list? Why do this result i small memory leaks?
FroglegPosted Jun 20, 2011, 5:12 AM