How can I find current thread\'s maximum stack size?
I am getting a stack overflow exception while executing a function from MMC UI but not from Powershell (command-
From Windows 8, there is the GetCurrentThreadStackLimits() function. You can use it from C# via PInvoke like this:
[DllImport("kernel32.dll")]
static extern void GetCurrentThreadStackLimits(out uint lowLimit, out uint highLimit);
uint low;
uint high;
GetCurrentThreadStackLimits(out low, out high);
var size = (high - low) / 1024; // in KB
On my machine, this yields 1MB in a console application, 256KB in a web application (IIS).