Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From this lecture from Simon Fraser University, what I understand is that each process gets a virtual address space allocated to it by the operating system. Here is a hypothetical question based on that. Suppose for a program the virtual address space allocated is from 100 -200. Now the stack grows from 200 downwards and heap from say 120 upwards. Now if the program requires more space, will the OS allocate address something like 400 to 900 and then copy over the data from old address space to new?

share|improve this question
up vote 1 down vote accepted

The stack grows down and the heap grows up, the space in between is known as the 'hole'. Generally sparse address spaces are used to keep holes for growth and DLLs. Generally the OS is good at allocating the proper amount of space initially, but if i recall in a demand paging system it would have to do a page replacement. How it does this depends on what algorithm is used (there are a few). This will give the program a larger frame of virtual memory to work with, so in basic terms your correct.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .