OutOfMemoryExeptions when swapping background image


Author
Message
Trond Borg
Trond Borg
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
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();
}
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic
4 active, 4 guests, 0 members, 0 anonymous
No members currently viewing this topic!

Login

Explore
Messages
Mentions
Search