After reading this and this post I ran a very simple C# program shown below:
static void Main(string[] args)
{
Thread t = new Thread(new ThreadStart(myFunc), 2097152);
t.start();
}
The second parameter to constructor of Thread
class is size (in bytes) of stack to be allocated for the thread. The number 2097152 is equivalent of 2 Mega Bytes. But my program still works without any error? Should my program not throw an error while allocating stack space (limit being 1 MB for full application itself) for this thread or I'm missing something very obvious. Initially I was thinking that this might be a compiler check itself.
How CLR ensures the stack allocation size for a thread so that it doesn't break the bounds?
P.S. : My application is 32-bit console application