不同程序是从公共堆还是从单独的堆中获取内存? [英] Do different programs gets their memory from a common heap or from a separate heap?

查看:83
本文介绍了不同程序是从公共堆还是从单独的堆中获取内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑linux上的glibc如何将其内存分配给各种程序.这些是几个问题:

I am a bit confused how glibc on linux allocates its memory to various program.These are the few questions:

  1. 它是从公共堆中分配的(即是否有公共堆 跨Linux中的所有进程)还是分配了一个堆 系统中的每个进程.

  1. Is it been allocated from a common heap(i.e is there a common heap across all of the processes in linux) or is there one heap allocated for every process in the system.

还假设如果我正在编译一个静态库,并且它最终被静态链接到主进程,它将如何获取其内存?它是否已经与其他一些堆链接(如我们已经编译的那样),或者将从主进程的堆中获取其内存.

Also suppose if I am compiling one static library and it finally gets statically linked to the main process, how it will get its memory? Is it already linked with some other heap(as we already compiled it) or will gets its memory from the main process's heap.

推荐答案

  1. libc意义上没有公共堆-这会违反进程保护和虚拟内存规则.每个进程都维护自己的堆.内核(借助处理器中的MMU)维护将虚拟地址映射到实际内存的虚拟内存表.

  1. There is no common heap in the libc sense - this would violate process protection and virtual memory rules. Each process maintains its own heap. The kernel (with the help of the MMU in the processor) maintains the virtual memory tables which map virtual addresses to real memory.

静态库只不过是在编译时链接代码-静态库没有运行时概念.它与进程相同,并且将使用其堆.

Static libraries are nothing more than linking code at compile time - there is no run time concept of a static library. It is one and the same as the process, and will use its heap.

这篇关于不同程序是从公共堆还是从单独的堆中获取内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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