Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.