🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2729

Re: Creating new TForm causes 'Out of Resources' error on WinXP

#2729
From: Dan Mayo
Date: Thu, 18 Jan 2007 20:23
64 lines
3264 bytes
> GDI resources are very limited.
Ok; I'll google this one to get a better idea...


> Available physical memory is different then available GDI resources.
Perhaps google will be my friend here too. :)

> Are you absolutely sure that 'delete' is always being called?  In any
> case, how much UI resources are you already using before creating the
> new form instance?
YES  There is no other way for the code to exit from that function.

> But what does the rest of your UI contain?
My whole user interface has a number of other buttons, labels, graphs, 
etc.  The weird thing I don't understand is that I am basically in a loop:

Simplified code is as follows:

void MyClass::TheLoop()
{
   bool Stop = false;
   while (!Stop)
   {
      TCustomForm *theDialogThatCrashes;
      theDialogThatCrashes = new TCustomForm(this);  //<-- This is where 
the out of resources occurs
      theDialogThatCrashes->Visible = true;
      TriggerLongHardwareRelatedTask();
      bool DoingSomeLongHardwareRelatedTask = true;
      while (DoingSomeLongHardwareRelatedTask)
      {
         //update the progress bar
	if (theDialogThatCrashes->ProgressBar->Position > 
theDialogThatCrashes->ProgressBar->Max)
          {
              theDialogThatCrashes->ProgressBar->Position = 0;
	 }
         else
	{
           theDialogThatCrashes->ProgressBar->Position += 1;
         }
	DoingSomeLongHardwareRelatedTask = !HardwareTaskComplete();
         Application->ProcessMessages(); //call this so that Button 
event on theDialogThatCrashes is called; the button event sets that 
forms Stopped boolean value to true if it is pressed
         if (theDialogThatCrashes->Stopped)
         {
           DoingSomeLongHardwareRelatedTask = false;
           Stop = true;
	}
      }
      theDialogThatCrashes->Visible = false;
      delete theDialogThatCrashes;
   }
}


For simplicity, the hardware event is sending a message out of the 
serial port and waiting for the RXBuffer on taht serial port to reach a 
certain byte level.

I don't see why I'm running out of resources with the above code.

Any suggestions?
Technical Details
Message-ID: <45afd751$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!213.132.189.2.MISMATCH!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45afcda9$1@newsgroups.borland.com> <45afd2ea$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,81568e00a202778e
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 18 Jan 2007 14:23:02 -0600
From: Dan Mayo <dmayo@dickey-john.com>
User-Agent: Thunderbird 1.5.0.4 (Windows/20060516)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Creating new TForm causes 'Out of Resources' error on WinXP
References: <45afcda9$1@newsgroups.borland.com> <45afd2ea$1@newsgroups.borland.com>
In-Reply-To: <45afd2ea$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 216.174.165.174
Message-ID: <45afd751$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1169151825 216.174.165.174 (18 Jan 2007 12:23:45 -0800)
Lines: 64
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!213.132.189.2.MISMATCH!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail