On occasion when GlobalAddAtom
is called I get a NULL Atom back. Formatting the error from GetLastError
shows "Not enough memory resources are available to process this command", but using Jordi Corbilla's Atom Table Monitor I can see that only about 2000 Global Atoms are used (1800 of which are RWM Atoms). What other system resources does GlobalAddAtom
require?
Background:
We have found in some cases that Delphi TBitBtn
would not draw (esp. on computer systems where two very large and complex Delphi application were repeatedly opened and closed). I found that FindControl
in vcl.Controls.pas would think it successfully found the Control Atom like this: GlobalFindAtom(PChar(ControlAtomString)) = ControlAtom
, but the ControlAtom
is actually NULL, so the test always incorrectly passes.
My first idea was that the Atom associated with ControlAtomString
was not properly disposed (earlier versions of Delphi did indeed have Global Atom leaks), and that the same string from a prior run was reused. Since its composed with an HInstance
and ThreadID
, the chances are slim, but not impossible. This was not the case. I could use Atom Table Monitor to verify the name was unused, plus the frequency of errors were too high to be name collisions
With this information I set off to see if I could trap any Atom errors and found the one listed in my more succinct question above.
A Minimum Reproducable Expample is not easy to create. The applications related to problem are very large and often need to run for several weeks, or opened and closed with a utility thousands of times before the problem rears its ugly head.
Once a system gets into a mode where this unknown system (global) resource is depleted the problem can be reproduced with relative frequency in any application with a TBitBtn
. A simple application with a single TBitBtn that is is opened and closed a few times (often only 3 or 4 times) will frequently fail to show the button