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



"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?
    ... 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)
  • Re: grassfire algorithm in java
    ... All you have is the stack overflow error message, ... >> rather long, uninformative stack trace, and no other options. ... along with the recursion count. ... void showResult{ ...
    (comp.lang.java.programmer)