As the title states: Is there any general "rule of thumb" about the size of the stack. I'm guessing the size will vary depending on the OS, the architecture, the size of the cache(s), how much RAM is available etc.
However can anything be said in general, or is there any way to find out, how much of the stack, this program is allowed to use?. As a bonus question is there any way (with compiler flags etc. (thinking mostly C/C++ here, but also more general)) that the size of the stack can be set to a fixed size by the user?
Btw, I'm asking strictly out of curiosity, I'm not having a stack overflow. :)
In Windows the default stack size for a thread is a million bytes, regardless of operating system, etc.
In managed code (C#, VB, etc) you can force a new thread to have a different stack size with this ctor:
http://msdn.microsoft.com/en-us/library/5cykbwz4.aspx
To change the stack size of the default thread of a Windows program, whether it is managed or not, you can use the editbin utility:
http://msdn.microsoft.com/en-us/library/xd3shwhf.aspx
Yes you can set the stack size, it usually is a linker flag, and it depends on your toolchain (typically this is referred to by the name of the compiler).
/F
option to change the size, andDUMPBIN /HEADERS
to see what the setting is.-Wl,--stack
You will also find several existing questions here on StackOverflow.