tags:

views:

1142

answers:

4

Hi All,

Could one say me how much the stack capacity is in C#. I am trying to form 3D mesh closed object by using an array of 30.000 items.

Thanks in advance

George ARKIN

+8  A: 

The default stack size for a .NET application is 1 MB (default is 256 KB for 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).

Brian Rasmussen
+6  A: 

The stack size is configurable and can be set in several different ways.

Dave Webb
+16  A: 

Your array will live on the heap, stack size is irrelevant in your case.

Anton Tykhyy
A: 

To use stack for storing an array you have to use unsafe code with pointers and stackalloc to allocate desired memory space on the stack.