Profile Picture

OutOfMemoryExeptions when swapping background image

Posted By Trond Borg 12 Years Ago
Author
Message
Trond Borg
sad Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 7, Visits: 1
I use the following function below to toggle between having a background image of a man or a woman for making indications of Medical symptoms. When toggling back and forth a few times, I am getting OutOfMemoryExeptions when trying to execute the codeline that creates a new BitMap.

I have done what I can to Dispose and restrict memory leaks, but it seems it is out of my hands. Is there any other way to prevent this from happening or does Nevron Diagram not have the ability to handle large images as background Pictures?

public void SetGender()
{
if (backgroundBMP != null)
backgroundBMP.Dispose();
NDrawingDocument1.BackgroundStyle.FillStyle.Dispose();
NDrawingDocument1.Dispose();
GC.Collect();

NDrawingDocument1 = new NDrawingDocument();
NDrawingView1.Document = NDrawingDocument1;

if (nRadioButton1.Checked)
backgroundBMP = new Bitmap("c:\\temp\\hiresmale.png");
else
backgroundBMP = new Bitmap("c:\\temp\\woman4000.jpg");

NDrawingDocument1.BackgroundStyle.FillStyle = new NImageFillStyle(backgroundBMP);
RefreshView();
}




Similar Topics


Reading This Topic