Stack capacity in C#

George ARKIN picture George ARKIN · May 5, 2009 · Viewed 38.3k times · Source

Could someone tell me what the stack capacity is in C#.

I am trying to form a 3D mesh closed object using an array of 30,000 items.

Answer

Brian Rasmussen picture Brian Rasmussen · May 5, 2009

The default stack size for a .NET application is 1 MB (default is 256 KB for 32-bit ASP.NET apps and 512 KB for 64-bit ASP.NET apps), but you can change that. For the application you can change the default size by modifying the PE header of the executable. For threads you create, you can use the constructor overload that takes a stack size.

But as Anton Tyjhyy points out in his answer, arrays are reference types and thus located on the heap (even if the array happens to hold a bunch of value types).