views:

11

answers:

0

In a ASP.Net web application, when you have a stack intensive operation to run, a stackoverflow exception is thrown on IIS when the stack size crosses the IIS set limit of 256K. A regular winform application however has a limit of 1MB. So the exception would not occur when running the same operation in a Winform application.

There is no recursion or any other code specific issues here.

There are ways to work around the problem like using EditBin on w3wp.exe, but it’s not supported.

Other option is to modify the actual code to reduce the size of locals and there by the stack size, which might involve significant design, code changes.

But the following approach solves the issue when running the Stack intensive operation on a separate thread, explicitly specifying the size of 1MB.

Thread thread = new Thread(() =>
{
    RunStackIntensiveOperation(someObject);
}, 1048576);
thread.Start();
thread.Join();

I am going with this 3rd approach. However, I am curious to see if anyone else had similar scenario and ran across issues due to the "operation on separate thread" approach.

What are the possible issues that might occur if I run a separate thread? What are the things to be aware of?

Opinions, suggestions please...