I have the following code:
private void picturebox_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Image tmp = img[selected].RenderImage(0); //This creates an Image object
e.Graphics.Clear(System.Drawing.Color.Black);
e.Graphics.DrawImage(tmp, movingPoint.X, movingPoint.Y, 512, 512);
tmp.Dispose();
}
This triggers when the user press PageDown, it basically displays the next image in list.
Now, I see my application memory going up and up and barely decreasing in regular intervals.
Am I disposing the tmp Image correctly? I think that's what is causing my memory issues.
Thanks.
Try:
tmp = nothing (or null - my VB and c# gets confused)
or
gc.collect()
which will force it to clear.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.