?
=?ISO-8859-1?Q?Mikko_Nyl=E9n?=
Is there a way to release the memory used while drawing a Bitmap using
Graphics.DrawImage?
The code I use:
--
....
using (Image im = Image.FromHbitmap(map.GetHbitmap()) {
g.DrawImage(im, 0, 0);
}
--
where "map" is an instance of Bitmap and "g" is instance of Graphics.
Now every time I draw the image, the memory usage increases by 0,5 MB
and doesn't decrease after it. It is a problem, because I must draw the
same Bitmap very often. A bit of moving mouse and Task Manager reports
that application is using over 300 MB of memory.
Minimizing the window and then maximizing it helps, but because I'm not
doing this for only myself, it's not a solution.
The solutions I have tried:
- call Graphics.Dispose() and recreate the Graphics object
before/after each redraw
- call Graphics.Clear before/after each redraw
- call System.GC.Collect() before/after each redraw
None of the solutions listed above haven't helped in any way.
- Mikko Nylén
Graphics.DrawImage?
The code I use:
--
....
using (Image im = Image.FromHbitmap(map.GetHbitmap()) {
g.DrawImage(im, 0, 0);
}
--
where "map" is an instance of Bitmap and "g" is instance of Graphics.
Now every time I draw the image, the memory usage increases by 0,5 MB
and doesn't decrease after it. It is a problem, because I must draw the
same Bitmap very often. A bit of moving mouse and Task Manager reports
that application is using over 300 MB of memory.
Minimizing the window and then maximizing it helps, but because I'm not
doing this for only myself, it's not a solution.
The solutions I have tried:
- call Graphics.Dispose() and recreate the Graphics object
before/after each redraw
- call Graphics.Clear before/after each redraw
- call System.GC.Collect() before/after each redraw
None of the solutions listed above haven't helped in any way.
- Mikko Nylén