Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GDI Error "Out of Resources" when there is plenty of resources

734 views
Skip to first unread message

Terrence Koehn

unread,
Jun 15, 2005, 2:38:01 PM6/15/05
to
As the development team we have been battling with random GDI errors for
years in our application built using Delphi 5. We have determined that
the "Out of Resources" message is completely bogus as we receive this
error on Win 2000/XP boxes when there is proven to be plenty of
resources. One of our frustrations is never being able to reproduce the
error in house. We use madExcept and the stack trace only shows VCL code.

The errors are completely random in nature, sometimes at launch of app.
or after the app. has ran for hours or days or never at all. Also each
build of the app. seems to produce a different pattern of errors (hard
to detect due to the random nature).

The reason for my post is in the latest build I can almost consistently
reproduce the error on my development machine. We have a ViewRegister
object that our "Views" (form units) use to register themselves during
unit initialization. When a "View" is added to the ViewRegister a TIcon
objects is created to hold the icon for the "View". The error occurs
when the "desktop" is creating a TImageList using the icons stored in
the ViewRegister.

ImageList.AddIcon(ViewRegister[i].IconImage) ends up calling
TIcon.HandleNeeded which calls function ReadIcon which calls CreateIcon
which is an API call (code is in Graphics.pas). CreateIcon returns a
0 so the VCL calls function GDIError. Now get this! If I put a break
point on Icon := CreateIcon(...) in function ReadIcon and pause for
several seconds the error NEVER happens! Without a break point the error
happens about 72% of the time. What is happening that would cause Win XP
to recover it's self by forcing a pause?

Now for my question. Is this a VCL/OS flavor problem? Is there some type
of bad code (improper type casting, etc) that could cause CreateIcon to
fail? All along we've suspected our code but when I found that a pause
causes the problem to resolve its' self I am now wondering about the VLC/OS.

Any insight into the internal working of the VCL and windows resources
would be appreciated. Any pointers on how to nail this one down?

Terrence Koehn
Orion Law Management Systems

Pete Fraser

unread,
Jun 16, 2005, 4:21:45 AM6/16/05
to
A pause can change the system timing which can stop events happening at a
time when you are not expecting it/them.
This sounds like a timing issue - have you got events happening recursively
etc.
Try putting breakpoints on event handlers and see if they happen
recursively.
With some events you must not call certain vcl functions while in the event
handler etc. Some code examples might help - even a cut down version of your
code that still exhibits the problem.
HTH Pete

"Terrence Koehn" <tko...@orionlaw.com> wrote in message
news:42b074ee$1...@newsgroups.borland.com...

<snip>


Terrence Koehn

unread,
Jun 16, 2005, 12:29:20 PM6/16/05
to
Could you be more spacific on "With some events you must not call
certain vcl functions while in the event handler etc."?

Unfortanatly with todays build I no longer can reproduce the error. As I
stated it is a moving target.

Pete Fraser

unread,
Jun 16, 2005, 12:58:06 PM6/16/05
to
For instance:
If you are in an event handler and change something that causes the event
handler
to be called again it goes round forever. And it can depend on when windows
sends a message to the VCL object as to whether it causes a problem or not.
HTH Pete

"Terrence Koehn" <tko...@orionlaw.com> wrote in message

news:42b1a842$1...@newsgroups.borland.com...

Koms Bomb

unread,
Jun 17, 2005, 2:10:19 AM6/17/05
to
> As the development team we have been battling with random GDI errors for
> years in our application built using Delphi 5. We have determined that
> the "Out of Resources" message is completely bogus as we receive this
> error on Win 2000/XP boxes when there is proven to be plenty of
> resources. One of our frustrations is never being able to reproduce the
> error in house. We use madExcept and the stack trace only shows VCL code.

I think GDI is global resource.
That's to say, if both of your app and all other apps running in the system
use too much GDI resource, maybe it will exceed the system limitation.

1, To reproduct that error, try to open as many big apps as you can, eg,
open several MS office, Delphi, etc, then run your app again.

2, "pause" problem maybe caused the system has freed some resouce
when you paused your app?

3, How big is your app? More than 1M source code lines?
If you app is too big, you should be careful to free unnecessary resouce
and re-create it when need. eg. don't create About dialog at startup,
only create it when the user click menu 'About'. :-)

4, There are always kinds of limitations in the OS, no matter it's 98 or XP.
So I think such error is most like caused by your own design.
Have you done some memory/resource leak test? If you haven't, do it now.


0 new messages