I think of stack and heap as referring to different sections of a process' virtual memory, where one grows upwards and the other downwards. Physical memory addresses (in the form of pages) are mapped to these virtual addresses. AFAIK, the addressing of the virtual address space is from 0x00000000 to 0xFFFFFFFF, which is humongous. Since the area between the stack and heap is so huge (most likely much larger than the actual physical memory on the computer), I don’t think the stack and heap can ever meet each other. Also, what then limits the amount of heap memory a program can ask from the OS?
User contributions licensed under CC BY-SA 3.0