The stack size limit is the maximum size of the stack for a process, in units of 1024 bytes. The stack is a per-thread resource that has unlimited hard and soft limits.
In Visual Studio the default stack size is 1 MB i think, so with a recursion depth of 10,000 each stack frame can be at most ~100 bytes which should be sufficient for a DFS algorithm. Most compilers including Visual Studio let you specify the stack size.
Stacks are temporary memory address spaces used to hold arguments and automatic variables over subprogram invocations. The default size of the main stack is about eight megabytes. Use the limit command to display the current main stack size as well as set it.
Stacks are temporary memory address spaces used to hold arguments and automatic variables during invocation of a subprogram or function reference. In general, the default main stack size is 8 megabytes.
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).
Your array will live on the heap, stack size is irrelevant in your case.
If you want to check the value for your current .NET assembly then you can do so by using ILDASM
command that comes in with Visual Studio command prompt. Once you have started the tool, open your assembly and then go to View -> Headers
menu. Now scroll down to PE Optional Header (32 bit)
section in the newly opened Headers
window. You will see two fields:
The said space is reserved in the operating system's paging file so the stack can always be swapped out when necessary.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With