Thread.StackSize

Out of interest, does anyone adjust the size of the stack allocated to their thread. I see on OSX the default stack size is 512kb. If I was working on some data intensive array manipulation for instance which exceeded 512kb would you advise increasing the stack size to suit if the thread required high speed processing. I assume if I don’t the data over 512kb is allocated dynamic memory which I assume would be slower.

What is the best way of determining the required stack size, would it be by the size of the data being manipulated within a thread?

Thread.StackSize doesn’t refer to general memory usage, but to the call stack. The call stack is the list of methods that haven’t returned yet. You only need to worry about the stack size if you expect very long chains of methods calling other methods, or are using recursion.

Thanks Andrew

it has to do with the size of each stack frame - not the total size of the call stack (which can grow to be as deep as available memory in your process allows)

whats a stack frame ? its the parameters + local variables + return address

ok … so you say “But I have a huge array as a local. OMG 512Kb wont be enough”
Well … internally whats on the stack is the reference to the array (4 or 8 bytes), same for strings, other class references etc
Most things are just pointers on the stack (you dont see this internal detail)

So 512Kb of references is a ton of them since most are 4 or 8 bytes

http://forums.realsoftware.com/viewtopic.php?f=1&t=13977