PancrasL的博客

虚拟内存地址

2020-11-15

image-20201115181629849

虚拟内存的地址空间

  • 虚拟内存的地址空间如下图所示

image-20201115181629849

  • 通过c程序进行验证

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    #include<stdio.h>
    #include<stdlib.h>

    int main(int argc, char const *argv[])
    {
    printf("code address: %p\n", main);
    printf("heap address: %p\n", malloc(10e7));
    int a;
    printf("stack address: %p\n", &a);
    return 0;
    }

    //out:
    code address: 0x7fa463a1f189
    heap address: 0x7fa45d880010
    stack address: 0x7fffc7df9124