Subj : Re: Best possible stack size for a thread To : comp.programming.threads From : Simon Bone Date : Sat Sep 17 2005 12:52 pm On Sat, 17 Sep 2005 00:16:20 -0700, jambu wrote: > Hi, > > I went thru the links , but they do not point me to the required > information . Even thou there is no harm in the memory being large , > iam eager to know is there any way to compute the memory consumption of > the thread. But why should the memory be wasted without being used ?? > The memory won't be wasted. Linux uses a virtual memory system and allocates pages of (typically) 4KB at a time. For the pages you use, you will get them assigned to your process, but for those you don't no real allocation will happen. All you are getting by default is 2MB of addresses *reserved* for use as the thread stack. That will be plenty for most uses, and so the most likely causes if you get stack overrun is a non-terminated recursion or a buffer overflow. I.e. programmer errors. You don't normally need to reduce the stack size, unless you want to stress test your application. Regards Simon Bone .