Re: Strange "Stack Overflow" message occurring with use of vector

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Igor,

You are correct, the issue is with the depth of my recursive routine.
As I understand it, each successive recursion stores info on the stack,
and when the allocated memory is all used up, it created a stack
overflow.

Thanks everyone for your assistance!

Igor Tandetnik wrote:
"ralphey" <Trapp.Andrew@xxxxxxxxx> wrote in message
news:1168490662.609154.101710@xxxxxxxxxxxxxxxxxxxxxxxxxxx
The only time I add elements to the vector is in a function which is
called recursively, and to do this I am passing the vector to the
function via reference (using the & operator); furthermore, the
recursion can be expected to run many (in the 1000's of) times in my
code.

I suspect the stack overflow has nothing to do with the vector, and
everything to do with running a recursive function 1000 levels deep. You
simply run out of stack for local variables. Replace your recursion with
iteration, possibly with an explicitly maintained stack.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925

.



Relevant Pages

  • Re: Any use for recursion?
    ... popped back off the stack, the program counter being changed again. ... Also, if the recursion is deep, e.g. 16 levels deep, then it results ... can be done with a plain loop can be done with a recursive function. ...
    (comp.programming)
  • Re: Any use for recursion?
    ... In modern languages there is no overhead. ... popped back off the stack, the program counter being changed again. ... Recursion is ubiquitous in modern software. ...
    (comp.programming)
  • Re: Memory management strategy
    ... >>trading memory for speed ... The use of registers instead of the stack doesn't need inlining. ... >longer instructions to access smaller data than they were optimized for. ... square) but it didn't need recursion or some kind of stack. ...
    (comp.lang.c)
  • Re: grassfire algorithm in java
    ... > How many recursions did it take to overflow the stack? ... > say, recursion counting does. ... For debugging it MAY be a useful technique - but you are talking about using ...
    (comp.lang.java.programmer)
  • Re: Is this tai-recursion?
    ... There is no difference between tail-recursion and iteration. ... That's why tail-recursion is so simple, ... fetch next instruction from instruction pointer ... instructions will manipulate the processor stack. ...
    (comp.lang.scheme)