Stack size for a thread

Sean Kelly sean at f4.ca
Tue Jul 24 17:21:53 PDT 2007


Ald wrote:
> Hello.
> 
> As I have read in ths docs, Phobos' threads allow me to specify the stack size.
> 
> What is the default size?

I believe it's whatever the OS default is.

> Suppose I know the maximum amount of functions a thread stack at any single time along with the variables.  How to I calculate the stack size in bytes, and is it a good idea to begin with?

I'd say don't bother unless you're creating tons of threads and running 
into memory problems as a result.  At that point, the easiest thing to 
do would be just to print the address of local variables in the root and 
the deepest thread function, do some subtraction, and fudge the number a 
bit :p  Also, since stacks are allocated in increments of one page, for 
most systems the stack you specify should generally be in multiples of 
4096 bytes.


Sean


More information about the Digitalmars-d-learn mailing list