Re: Strange "Stack Overflow" message occurring with use of vector
- From: "ralphey" <Trapp.Andrew@xxxxxxxxx>
- Date: 16 Jan 2007 17:33:39 -0800
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
.
- References:
- Strange "Stack Overflow" message occurring with use of vector
- From: ralphey
- Re: Strange "Stack Overflow" message occurring with use of vector
- From: Igor Tandetnik
- Strange "Stack Overflow" message occurring with use of vector
- Prev by Date: Re: Must compile all with _SECURE_SCL setting?
- Next by Date: Shell commands and other executables
- Previous by thread: Re: Strange "Stack Overflow" message occurring with use of vector
- Next by thread: How to make a variable unique in the program?
- Index(es):
Relevant Pages
|