Soumen
Soumen

Reputation: 1078

Virtual memory allocated to a process

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

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

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

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

Upvotes: 2

Views: 957

Answers (2)

qre0ct
qre0ct

Reputation: 6162

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.

Upvotes: 2

Jason
Jason

Reputation: 3917

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...)

Upvotes: 2

Related Questions