Showing posts with label IIS Stack Size. Show all posts
Showing posts with label IIS Stack Size. Show all posts

Monday, June 17, 2013

Stack Overflow exception Stack sizes in IIS

Hi,

We encountered a problem with decreased stack size of  IIS 6.0.

Problem:
As Stack size of IIS 6.0 is decreased to 256kb,we may get problem with executing recursive functionality up to some level or executing a method that processing heavy data.

We will get Stack OverFlow exception, when stack size of server(IIS) is not sufficient to serve the request.

Info: All the IIS versions below IIS 5.1, Stack size of a process is limited to 1MB.


Solution:
It is better to run a thread exclusively for the method which is causing exception like below.

protected void Button1_Click(Object Sender,EventArgs e)
{
Thread thread = new Thread(() => download(filename),4194304);
         thread .Start();
          thread .Join();
}



Explanation:
in Above thread,download is method name and filename is parameter.
4194304, 4 MB stack size is allotted to serve this request.



Thanks and Regards,
Hari