用户空间中堆栈和堆的内存布局 [英] memory layout of stack and heap in user space

查看:441
本文介绍了用户空间中堆栈和堆的内存布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近正在研究操作系统,这是一张在线图片,显示用户空间和内核空间的内存布局以及堆栈,堆等的布局.
在此图中,我看到堆栈位于用户空间中的最高内存地址上,高于堆,数据段等.

I'm recently studying the OS, and here is a picture online showing the memory layout of user space and kernel space, and the layout of stack, heap and so on.
In this figure I see that the stack is at the highest memory address in user space, higher than the heap, data segment and so on.

为了确认这一点,我在调试视图下的vs2012中使用了内存监视程序窗口,这是我的代码:

In order to check that, I used the memory watcher window in vs2012 under debug view, here's my code:

int a = 3;

int main()
{
    int b = 5;  
    int *p = new int[100];  
    delete [] p;
    return 0;
}

然后我检查了a(data segment),b(stack variable) and p(heap)的内存地址,但是我发现b的地址是最低的,那么为什么结果与上图不同?

And I checked the memory address of a(data segment),b(stack variable) and p(heap), but I found the address of b is the lowest among the three, so why is the result different from the picture above?

推荐答案

该图像看起来像Linux布置虚拟地址空间而不是Microsoft Windows的布局.

That image looks like how Linux lays out the virtual address space, not Microsoft Windows.

这篇关于用户空间中堆栈和堆的内存布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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