PDA

View Full Version : [SOLVED] gcc / g++ increasing stack size



zobayer1
May 6th, 2011, 08:55 AM
In windows, visual c++ has a pragma which can be used to increase the function stack size. And in linux, this can be done by giving compiler options, but is it possible to do it from inside the code? like the way vc did?

I need to know it, because heavy recursions and long depth dfs calls get Runtime Errors because of stack overflow :(

Phenax
May 6th, 2011, 10:06 AM
http://linux.die.net/man/2/setrlimit

zobayer1
May 6th, 2011, 12:37 PM
wow, nice, thanks :):KS

schauerlich
May 6th, 2011, 08:29 PM
I need to know it, because heavy recursions and long depth dfs calls get Runtime Errors because of stack overflow :(

Increasing the stack size might alleviate the problem temporarily, but it's just delaying it until the problem grows again. It's probably best to find some way of converting your algorithm to a tail recursive or iterative algorithm.

zobayer1
May 6th, 2011, 08:34 PM
Sometimes writing iterative algorithms seems difficult to me, instead, recursions are so clear to visualize... That's why I asked :)