views:

361

answers:

2

how do i debug something like this? i need the debugger to stop and show me where the problem is. don't just show it in the event log & then hang.

first chance exception: system error 8: not enough storage space to perform the command

i'm using delphi 2009. the problem doesn't happen regulary. i'm not eager to pepper my program with OutputDebugString calls to track this down!

thank you for your help!

+3  A: 

You are looking at a resource leak on your server, more than likely... Either handle related, or memory related...

I've had this happen a lot, and it's always the case... There CAN be other causes, but I think a resource leak is your #1 cause...

You are going to have to either find it and fix it, or start putting debug checks in on all memory allocations, handle allocations, and log them anytime you can't get memory, or handles.

It's also possible that your CLIENT machine is out of resources, but usually, it's the server at fault...

Failing all that, give us some more idea of what you are doing, what the code looks like, etc, to help spot issues. Just based on the error alone, isn't a lot to go on...

LarryF
it's a desktop app that uses a local Access database. the computer shouldn't be out of any resources. i was hoping the debugger could be coaxed to stop when such an error occurs. i have about 10 years delphi experience and this is only the 2nd error like this that i have ever seen!
X-Ray
more to the point, i don't yet know where in the code it's happening. it's about a 60,000 line program that uses a 3rd party graphing engine and a C/C++ DLL that communicates with an instrument. there's a lot going on here...
X-Ray
Well, is the error thrown as an exception, or it's just showing up in your event log? For an error like this, your code would HAVE to respond in SOME way, even if you caught it... If not, then it may not be your code at all, but a leak somewhere that causes a service, etc to throw, and evtlog it.
LarryF
If you can, go into your IDE to the exception handling for the debugger. You can force it to stop on first chance exceptions, and break. I don't know the Delphi IDE, but in Studio, it's Debug->Exceptions (CTRL-ALT-E). Then check the box under "Thrown". If it's not listed, add it.
LarryF
thank you for your response! it's just showing up in your event log. after that, it hangs. i don't know of a way to do what you suggest in the delphi ide. i know of the feature you mention in the MS IDE. i think i MAY now know the cause of the problem. it hasn't happened yet today.
X-Ray
today i changed the code to limit a very bad design decision made by the project manager. he wanted a cascaded popup menu that has (ummmm) about 2000 menu items. today the first thing i did was limit it to 500. when it got in trouble it has shown a msg about: too many menu items...out of resources
X-Ray
X-Ray
Wow.. That's a pretty big menu.. :) Each item has handles, and memory, etc.. That may be the root cause of the whole issue, just running out of handles... Well, I hope this was the fix, but you might want to let the app act up, then look at it with procexp, or taskman and check the handle count
LarryF
yes; i told them it was a dumb idea. i agree; i want to see it happen again to try to prove this is the cause. will get back to you.
X-Ray
A: 

If your program uses a lot of windows resources it could be a Resource Heap shortage.

There is a registry entry that can be increased to raise the heap size for XP. For Vista Microsoft already sets the default value higher. I recommend changing the default 3072 to at least 8192.

This information is documented in the Knowledge Base Article ID 126962 (or search for "Out of Memory"). Additional details concerning the parameter values may be found in the Knowledge Base Article ID 184802.

I suggest you read the knowledgebase article but the basic info on the change is:

1) Run Registry Editor (REGEDT32.EXE).

2) From the HKEY_ LOCAL_MACHINE subtree, go to the following folder:

   \System\CurrentControlSet\Control\Session Manager\SubSystem

3) On the right hand side of the screen double-click on the key:

   windows

4) On the pop-up window you will see a very long field selected. Move the cursor near the beginning of the string looking for this (values may vary):

   SharedSection=1024,3072,512

5) SharedSection specifies the System and desktop heaps using the following format: SharedSection=xxxx,yyyy,zzz where xxxx defines the maximum size of the system-wide heap (in kilobytes), yyyy defines the size of the per desktop heap, and zzz defines the size of the desktop heap for a "noninteractive" window station.

6) Change ONLY the yyyy value to 8192 (or larger) and press OK.

7) Exit the Registry Editor and reboot the PC for the change to take effect.

Good Luck

Steve Black