问题描述
直到现在使用Linux(堆栈地址非常高且堆地址非常低)(通过使用C程序打印堆和堆栈地址可以看到),我在Win32进程内存布局方面遇到了问题. MWSDN表示堆栈地址比堆地址高,但是根据我的实际经验,堆栈地址比堆地址低.所以我很困惑.有人请解释.
Working with Linux until now where stack addresses are very high and heap addresses are pretty low (as seen by printing heap and stack addresses using a C program), I have a problem with the Win32 process memory layout. MWSDN is saying that that stack addresses are higher than heap addresses, but from what I saw in practice, stack addresses are lower than heap addresses. So I am confused. Someone please explain.
推荐答案
Hm,stack addresses are higher than heap addresses
-这根本不是事实.堆栈和堆都可以驻留在Windows上进程的地址空间中的任何位置.
Hm, stack addresses are higher than heap addresses
- this is simply not true. Both stack and heap can reside anywhere in the address space of the process on Windows.
如果启动大量线程,进行大量堆分配并加载数百个dll,您会发现所有这些对象均在地址空间中均匀分布.
If you start a lot of threads, make huge heap allocations and load hundreds of dlls, you will find that all these objects are evenly spread around the address space.
此图显示了Windows上典型的32位进程中虚拟分配的结构.绿色表示自由区域,蓝色表示已分配了一些空间.活动主要发生在地址空间的开头,但在其他地址范围中也存在.
This picture shows the structure of virtual allocations in a typical 32-bit process on Windows. Green shows free areas, blue that something is allocated. Activity is mostly taking place in the beginning of the address space but in other address ranges it is present also.
这篇关于Windows堆栈和堆地址范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!