将多少堆栈存储器分配给程序 [英] How many stack memories will be allocated to a program

查看:65
本文介绍了将多少堆栈存储器分配给程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,它有4个项目作为依赖项(这意味着它必须加载4个dll来运行该程序)。操作系统是否分配4个堆栈内存或者只为整个程序分配1个堆栈内存以及如何将为程序分配多少堆栈内存大小?

I have a program which have 4 projects as dependency for that (that means it has to load 4 dlls to run that program) .Does the OS allocates 4 stack memories or only 1 stack memory will be allocated for whole program and how much stack memory size will be allocated for the program?

推荐答案

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



这不是严格准确的(因为有)一个单独的堆栈,供您的应用程序可以与之交互的设备驱动程序使用,但它足够准确,适用于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]


这篇关于将多少堆栈存储器分配给程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆