Virtual memory allocated to a process

I have been reading virtual memory, paging etc. I have some doubts regarding this.

  • When a process is created, what is its virtual address space size?

  • Is the size different for different processes? If yes, then how is it decided?

  • If the process needs more virtual address space during its run, how the extra amount of memory allocated to it?


  • I'll try to answer in the order you asked.

  • There isn't a fixed initial size of a process
  • Yes, the amount of memory mapped to a process depends on the size of the executable text/data sections, linked objects, initial stack size, and initial heap size. The stack grows automatically as referencing addresses on the stack cause page faults.
  • Additional non-stack memory is mapped to a process through a request to the operating system through a system call (sbrk(), mmap(), etc...)

  • It was a brilliant brief explanation by Jason. Just to add to it and to bring more clarity, I would suggest you also understand the format of an executable image, for example the ELF, itself. ELF executable explained would be a good place to get a basic understanding. You may also find connection between ELF (segments - loadable sections of an ELF executable) and VM useful.

    An understanding of the basic executable image and what are the various components of it will supplement Jason's answer and also your understanding of how exactly is a decision made as to how much virtual memory to allocate to a process.

    I know my answer is very late with respect to when you asked the question itself, but hopefully it helps. And in case you find something more interesting and insightful, please share it here so others too would be educated.

    链接地址: http://www.djcxy.com/p/80188.html

    上一篇: 如何计算任务管理器的内存使用情况?

    下一篇: 分配给进程的虚拟内存