« Getting together in B… | Home | Greetings from Birmin… »

Tip of the night: Thread Stacksize


The stack size of threads is an issue. It can cause random crashes. For code in Real Studio, there is extra code inserted in every method to ensure you get a StackOverflowException. But in C code, this check is not performed. So if you have a full stack and you call into the Real Studio runtime, some DLL or a plugin, the function can overwrite the some objects in memory located behind the end of the stack.
With a tiny stack of just 64 K by default on Mac this is very likely to happen with a little bit of recursion.
So please set stacksize to a higher value like one million bytes.
Also sign on this bug report: 22996: Increase default Thread.Stacksize
02 11 12 - 00:35
two comments

Very interesting.

Some of my users have been trying to run on inexpensive XP notebooks and getting stack errors which do not appear on larger windows machines.

I am very interested in trying your stacksize solution for these users.
Michael Bedesem - 02 11 12 - 00:56

What about the main thread? It is not accessible but has REAL changed the default thread size? I have some methods which use recursion – is the recommendation now to run them in a thread? How would one calculate how much size is needed?
Markus Wnter - 02 11 12 - 09:19


  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.