System.OutOfMemoryException in System.Drawing.dll

  • Thread starter Thread starter Evan
  • Start date Start date
E

Evan

I've been working on a Windows Forms application for some time now,
but I'm having some trouble when I call Application.DoEvents(). When I
do this after the program has been running for a few hours it causes a
System.OutOfMemoryException to be thrown in System.Drawing.dll. Can
anyone steer me in the right direction as to why this is occurring and
how I can fix it?

Evan
 
I can't post all of my source since there are well over 20,000 lines
spread across multiple documents. However, here's part of a function
where such an event occurs:

array<double, 2> ^CalculateNormedArray(array<double, 2> ^% abs, double
max, double min) {
StatusBox ^sb = gcnew StatusBox();
sb->DescriptionText = "Processing normalized array...";
sb->ProgressBar->Value = 0;
sb->Show();
array<double, 2> ^retval = gcnew array<double, 2>(1280, 1024);
for(int y=0;y<1024;y++) {
for(int x=0;x<1280;x++) {
retval[x, y] = (abs[x, y] - min) / (max - min);
}
if(y % 16 == 0) {
sb->ProgressBar->Value = (double)y / 1024.0;
Application::DoEvents(); // <-- Exception occurs on this
line
}
return retval;
}

The exception doesn't occur the first time Application::DoEvents() is
called, but after a few times. As you can see, I'm not creating any
new objects in this loop, which is one of the reasons I'm baffled as
to why I'm getting an OutOfMemory exception.

Evan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top