CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2001
    Location
    Sarawak,Malaysia
    Posts
    5

    out of stack space error

    does anyone know how to extend the stack space or flush a stack ? i'm working with nested loops and can't find a way to get around this problem...anyone?


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: out of stack space error

    "i'm working with nested loops "

    You sure each loop has an exit that will be sured reached (non infinite loop)?



    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: out of stack space error

    ...and beware of recursion, too...

    Have nice streets under your wheels

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Apr 2001
    Location
    Sarawak,Malaysia
    Posts
    5

    Re: out of stack space error

    its kind recursive too...i've terminated every if
    with an end if..my problem is that it uses an algorithm that searches its methods and uses them recursively..over and over again. There's no infinite loop its just that i need a bigger stack space (if possible) or a way to overcome this problem. Thanks for your replies anyway!


  5. #5
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: out of stack space error

    If you are using recursion, you should optimise your function for recursion. Make it small and efficient. Use as less variables in it as possible. Use less variables as parameters.

    If your algorithm is eating up all of tha available stack space, then you'd better consider a solution that replaces the recursion with an iteration. There is almost always an iterative counterpart to a recursion. Memory requirement of an iterative solution is not a big problem because then you can use dynamic arrays. And you'll get an added speed advantage if you use iteration instead of recursion.


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