zoukankan      html  css  js  c++  java
  • 进程中内存地址空间的划分

    void fcn(int A, int B){
        int C;
        int D;
    }
    
    高地址 命令行参数信息,环境表信息
    : 栈Stack for thread 0:一个线程一个私有栈
    : 栈里的栈帧Stack Frame 0:一个函数里的局部变量一个栈帧
    : 栈里的栈帧Stack Frame 1:设这个是fcn(),依次将BACD压入栈
    : ::::
    : 映射区
    : ::::
    : 堆Heap:用户自己分配内存
    : BSS(Data):global,static数据
    : 全局区/数据区(Data):initialized global, static数据
    : 只读常量区(Text):const initialized global, static数据
    低地址 代码区(Text):存储二进制指令

    Note:

    1. BSS段(Data)会在main函数执行之前自动清零没有初始化的g_var此时被初始化
    2. 堆区(Heap)中的内存空间由程序员手动申请以及手动释放, 该区域中的内存空间由OS自动管理
    3. 一个进程一个堆,堆≈虚拟物理内存-1GB,
      一个线程一个栈,栈通常为4MB
      堆的大小实际上(运行时)动态变化的,但有理论最大值,理论上虚拟内存有多大,就可以(近似)建多大,但32位的程序在64位系统上运行的时候,一个进程的堆大小应该是不可以超过4G的.
      栈大小固定(编译时确定),linux系统下默认栈大小是10M,windows系统下默认栈大小是1M,当然了,都是虚拟的
    4. stack frame VS program stack VS heap=>the program stack is an area of memory that supports the execution of functions and is normally shared with the heap—they share the same region of memory , the program stack tends to occupy the lower part of this region ,while the heap uses the upper part.The program stack holds stack frames(栈桢), sometimes called activation records or activation frames. Stack frames holds the paramaters and local variables of a function. Local variables are also called automatic variables。 They are always allocated to a stack frame
    5. ANSI C编程可以使用malloc()/free()进行动态内存分配,Unix/Linux平台还可以使用sbrk()/brk(),mmap()/mumap()
  • 相关阅读:
    数据分析和个人提升
    数据分析和个人提升
    如何用SPSS做联合分析
    如何用SPSS做联合分析
    SPSS与Streams的集成实现实时预测
    互联网时代的精准招聘-Uber新手游有感
    OSEck中odo_vect2pcb的作用
    PHP收邮件receiveMail
    Android调试优化篇
    JSP之Model1
  • 原文地址:https://www.cnblogs.com/xiaojiang1025/p/5933463.html
Copyright © 2011-2022 走看看