|
-
March 17th, 1999, 12:19 AM
#1
Out of Stack Space
What does this error message mean? And how can I get rid of it??
-
March 17th, 1999, 05:39 AM
#2
Re: Out of Stack Space
Hi
This error usually happens when a routine is called recursively (i.e. it calls itself - usually without you knowing).
For example, the _Paint event can be triggered to call itself, as can the _Resize event.
A simple way to stop this happening is to check within the procedure causing the error :
eg.
Private Sub Form_Resize() ' Or XXControl_Resize or XX_Paint or Whatever
Static bAlreadyInHere As Boolean ' Static variable to hold state
If bAlreadyInHere Then Exit Sub
bAlreadyInHere = True
'
' Do Stuff
'
bAlreadyInHere = False
End Sub
Regards
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
May 26th, 1999, 07:35 AM
#3
Re: Out of Stack Space
Everytime a function (or sub) is called the compiler has to do some things.
First it needs to know, who called the function (that is the "Where do I have to jump, when this is all over?" - address).
Second it needs to keep the local variables somewhere. This is all done in the "Stack". When the function exits the stack is deleted.
When you call another function in this function the compiler (as above) remembers the returnadress, reserves space for local variables and so on.
Under Win32 (NT, 95/98) the stack space is huge (normally about 1Meg, but easily more) compared to 64K in good ol' 16 Bit times.
But even 1 meg is eventually full ...
Normally this shouldn't be a problem (remember : it worked with 64K ...), but when you carelessly use rekursive functions (and VB does
a lot of them (Events that fire themselfes...)) you wil go "Out of Stack Space" ...
So, if you use rekursive functions : keep the memory-footprint small (e.g. don't pass Strings ByVal,...) and always make sure the rekursion terminates ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|