且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将多少堆栈存储器分配给程序

更新时间:2023-02-11 19:42:51

取决于:堆栈与应用程序运行的每个线程相关联:所以如果它只启动一个线程 - 它是主线程 - 并且不再做任何事情,然后它将获得一个且只有一个堆栈。



这不是严格准确的(因为有)一个单独的堆栈,供您的应用程序可以与之交互的设备驱动程序使用,但它足够准确,适用于99.99%的应用程序!



实际大小堆栈在构建时是可变的(参见 MSDN:/ F标志 [ ^ ])也可能因应用程序运行的环境而异。它在运行时不会改变。



错字[/ edit]
Depends: a stack is associated with each thread that the application runs: so if it only ever starts one thread - it's main thread - and doesn't do anything to start any more, then it will get one and only one stack.

That's not strictly accurate (as there is a separate stack that is used by device drivers that your app may interface with and such like) but it's accurate enough for 99.99% of applications!

The actual size of the stack is variable at build time, (See MSDN: /F flag[^]) and also may vary depending on the environment your app runs in. It does not change at run time.

[edit]Typo[/edit]