How do I change the size of the stack in c++? I would like to use larger arrays, and the stack overflows when I make them as large as I would like.
Thanks,
MadCow
Printable View
How do I change the size of the stack in c++? I would like to use larger arrays, and the stack overflows when I make them as large as I would like.
Thanks,
MadCow
Use std::vector?
Thanks, that does the trick. Will I notice any difference performance wise?
You shouldn't, vectors shouldn't be much slower then an array, if not the same.
> How do I change the size of the stack in c++?
It depends on your OS and compiler.
Besides, as Hunter2 suggested, take it as a hint that you should be looking for a better solution ;)
Thats interesting I though the stack was suposed to grow when all of it's space was used up?
Quote:
Originally Posted by MadCow257
http://www.artima.com/intv/goldilocks.htmlQuote:
Originally Posted by Bjarne Stroustrup
Just out of curiosity, why would you think that?Quote:
Thats interesting I though the stack was suposed to grow when all of it's space was used up?
> Thats interesting I though the stack was suposed to grow when all of it's space was used up?
That depends....
Just a little under 2MB here.Code:$ ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 2043
cpu time (seconds, -t) unlimited
max user processes (-u) 63
virtual memory (kbytes, -v) 2097152
Of course I could set "unlimited", but it would still be limited by the very real limits of physical memory / swap space / address space.
How you manipulate the same thing in say windows is another matter.
You can't just put char x[1000000] inside a recursive function and sit back hoping that it'll work.