CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 1999
    Posts
    1

    Out of Stack Space



    What does this error message mean? And how can I get rid of it??

  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    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



  3. #3
    Guest

    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
  •  





Click Here to Expand Forum to Full Width

Featured