Thread Stack Size
来源:互联网 发布:京都工艺品淘宝 编辑:程序博客网 时间:2024/06/07 15:58
- MSDN Home
- MSDN Library
- MSDN Learn
- MSDN Downloads
- MSDN Support
- MSDN Community
- Design Tools
- Development Tools and Languages
- Mobile and Embedded Development
- .NET Development
- Office Development
- Open Specifications
- Servers and Enterprise Development
- Web Development
- Win32 and COM Development
- Administration and Management
- Component Development
- Data Access and Storage
- Development Guides
- Diagnostics
- Graphics and Multimedia
- Messaging and Collaboration
- Mobile PC
- Networking
- Security
- System Services
- Tools
- User Interface
- Windows Search
- Windows Driver Kit
- Windows Logo Kit
- Windows Versions
- XML
- Technical Articles
- Multitasking
- Scheduling
- Multiple Threads
- Child Processes
- Thread Pools
- Job Objects
- Fibers
- Thread Stack Size
- Thread Handles and Identifiers
- Suspending Thread Execution
- Synchronizing Execution of Multiple Threads
- Multiple Threads and GDI Objects
- Thread Local Storage
- Creating Windows in Threads
- Terminating a Thread
- Thread Security and Access Rights
Eachnew thread or fiber receives its own stack space consisting of bothreserved and initially committed memory. The reserved memory sizerepresents the total stack allocation in virtual memory. As such, thereserved size is limited to the virtual address range. The initiallycommitted pages do not utilize physical memory until they arereferenced; however, they do remove pages from the system total commitlimit, which is the size of the page file plus the size of the physicalmemory. The system commits additional pages from the reserved stackmemory as they are needed, until either the stack reaches the reservedsize minus one page (which is used as a guard page to prevent stackoverflow) or the system is so low on memory that the operation fails.
Itis best to choose as small a stack size as possible and commit thestack that is needed for the thread or fiber to run reliably. Everypage that is reserved for the stack cannot be used for any otherpurpose.
A stack is freed when its thread exits. It is not freed if the thread is terminated by another thread.
Thedefault size for the reserved and initially committed stack memory isspecified in the executable file header. Thread or fiber creation failsif there is not enough memory to reserve or commit the number of bytesrequested. The default stack reservation size used by the linker is 1MB. To specify a different default stack reservation size for allthreads and fibers, use the STACKSIZE statement in the moduledefinition (.def) file. The operating system rounds up the specifiedsize to the nearest multiple of the system's allocation granularity(typically 64 KB). To retrieve the allocation granularity of thecurrent system, use the GetSystemInfo function.
To change the initially committed stack space, use the dwStackSize parameter of the CreateThread, CreateRemoteThread, or CreateFiberfunction. This value is rounded up to the nearest page. Generally, thereserve size is the default reserve size specified in the executableheader. However, if the initially committed size specified by dwStackSizeis larger than or equal to the default reserve size, the reserve sizeis this new commit size rounded up to the nearest multiple of 1 MB.
To change the reserved stack size, set the dwCreationFlags parameter of CreateThread or CreateRemoteThread to STACK_SIZE_PARAM_IS_A_RESERVATION and use the dwStackSizeparameter. In this case, the initially committed size is the defaultsize specified in the executable header. For fibers, use the dwStackReserveSize parameter of CreateFiberEx. The committed size is specified in the dwStackCommitSize parameter.
The SetThreadStackGuaranteefunction sets the minimum size of the stack associated with the callingthread or fiber that will be available during any stack overflowexceptions.
Send comments about this topic to Microsoft
Build date: 8/7/2008
- Thread Stack Size
- Using -Xss to adjust Java default thread stack size
- THREAD STACK
- C51: CALCULATING STACK SIZE
- overflow与VC stack size参数/stack:
- Difference between Stack.capacity() and Stack.size()
- python thread stack trace
- Thread stack overrun
- Pool thread stack traces
- 关于gcc的stack size
- VM args -Xss160k stack size
- Maximum call stack size exceeded
- Maximum call stack size exeeded
- Maximum call stack size exceeded
- Microsoft.Excel.Formula.Size.Stack.Overflow
- HP-UX如何修改stack size
- 未知异常: Maximum call stack size exceeded
- pthread中的stack size的设置
- 行转列 或 转置问题
- 如何写外企求职信
- 检测内存泄露的方法:
- μC/OS-II是一个基于抢占式的实时多任务内核
- 将Js文件编译成dll文件
- Thread Stack Size
- jImage- 图像服务器
- myeclipse快捷键设置
- Visual C++剪贴板操作
- 电信SOC网站安全监测与防护系统技术方案
- 函数malloc()和calloc()的区别
- 非常详细的虚拟语气讲解,四六级绝对有用
- stdext::hash_map
- spring连接oracle10g和sqlserver