I am saving a screenshot of current image on the computer:
Rectangle bounds = Screen.GetBounds(Point.Empty);
using (var bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
using (var mss = new MemoryStream())
{
bitmap.Save(mss,ImageFormat.Gif);
}
}
And the memoryleak is at this code:
bitmap.Save(mss,ImageFormat.Gif);
Shouldn't my use of using
dispose everything I am using?
Why am I still getting really high memory usage when taking lots of pictures and the memory ain't released back?
Thank you!