tags:

views:

55

answers:

1

Hi there, I am working with scons and am trying to compile a program that require bigger stack size but I dont know how to extend the stack size. This is on a solaris machine, and we use scons to compile our projects.

Anyone know how to do this ?

A: 

In the shell (ksh example) prior to executing your program you can use ulimit -s <size in kbytes>. You may need elevated privileges to change it.

You can also use setrlimit programmatically but from the man page it won't adjust the currently running process so it's probably not helpful for your needs.

Also consider what about your program needs the larger stack size. Is there a way you can change your design to be more stack friendly? The Solaris default seems to be 10M which is a fairly large stack.

Mark B
For example, move variable allocation to dynamic allocation using `new`. Most platforms have a lot more memory in the dynamic memory than for locals (i.e. stack). Also, check for recursive calls and function call depth. Passing many variables by structure rather than parameter list may save some stack space.
Thomas Matthews
On the other hand, stack allocation is faster than heap allocation so if you know you'll need lots of objects / calls and don't want to lose speed, stack allocation seems fair game. (ah, if only we had unlimited stack size like Go :x)
Matthieu M.
On the third hand, if you're using tons of objects, they're probably fairly small and a simple small object allocator might be a good way around the stack limitations.
Mark B