Reputation: 759
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.
Upvotes: 1
Views: 659
Reputation: 2522
Try:
tmp = nothing (or null - my VB and c# gets confused)
or
gc.collect()
which will force it to clear.
Upvotes: 1