Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase Stack size IIS ASP.NET 3.5

I understand that the default max stack size on ASP.NET was decreased to 256K instead of 1MB (see http://support.microsoft.com/kb/932909), how can I get it back to 1MB?

like image 645
Haim Bender Avatar asked Feb 23 '10 16:02

Haim Bender


People also ask

Can stack size increase?

You may need to increase the stack size if your program gets stack-overflow messages at runtime. You can also set the stack size by: Using the /STACK linker option. For more information, see /STACK (Stack allocations).

What is the maximum size of stack?

In Microsoft Windows 2000, if the Microsoft ASP.NET Worker Process (ASPNet_wp.exe) creates a thread, the maximum stack size of the thread is 1 MB. In Windows Server 2008 and higher, the maximum stack size of a thread running on 32-bit version of IIS is 256 KB, and on an x64 server is 512 KB.

Why is stack size limit?

Because all threads in a process share the same address space, they have to divide it between them. And after the operating system has taken its part, there is "only" 2-3 GB left for an application. And that size is the limit for both the physical and the virtual memory, because there just aren't any more addresses.


2 Answers

You can use editbin, as described in this article.

like image 117
Oded Avatar answered Oct 06 '22 03:10

Oded


Another solution could be that of creating an explicit new thread to perform the operations where you're getting a stack overflow error

  Thread t = new Thread(Run, 4194304); // 4M of stack size
  t.Start();
  t.Join();
  if (loadException != null) throw loadException;

  void Run()
        {
            try
            {
              // Operation causing stack overflow
            }
            catch (Exception e)
            {
              ...
            }
        }

Regards

Massimo

like image 44
massimogentilini Avatar answered Oct 06 '22 03:10

massimogentilini