stack memory location
i know the heap memory is the part of ram. but is stack memory also the part of ram or stack memory is the part of cpu registers. what is the default size for stack memory for .net4.0 开发者_运维知识库applications
The stack memory is a part of RAM. It is no different from the heap as far as the computer is concerned. It's only used in a different way.
Typically, program code space and heap memory are allocated from the bottom (starting at zero) of the memory space, on up. Commonly, stacks start at the extreme top of the memory space and grow downward. The initial stack size can be very small (one page), because when you outgrow it, a page fault will occur, and the OS can allocate more space, growing downward.
Incidentally, in 64-bit x86 processors, there is a big "gap" in the middle of the 64-bit address space, because the machine doesn't implement full 64-bit addressing. See this on wikipedia.
what is the default size for stack memory for .net4.0 applications
This is common for .Net and non-.net Windows applications. It is allocated per-thread. Each thread has its own stack. The typical amount is 1 MB. The default can be overridden:
- Per executable by controling exectuable headers. There's
/STACK
option in C++ compiler, so you can set that if you use C++/CLI to create .NET executables. Apparently, there's no option to control that in C# or F# though. - Per thread.
System.Threading.Thread
has a constructor overload that takes stack reservation as one of the parameters.
精彩评论