memoryheap-memorystack-memory

Amount of Heap & Stack on a PC


What is the amount of heap and stack available to a Program and how do I determine it? And is it dependent on the compiler or PC or both?


Solution

  • It's "unlimited" :]. Every process receives a virtual address space which is only limited by CPU and OS implementation. If a CPU or OS is 32 bit, then the process gets a possibility to address ~4GB of virtual memory (even if you have less RAM installed in your PC). On a 64 bit CPU and 64 bit os, current implementations limit the virtual address space to 48 bit, so a process believes that it can use up to 256TB of memory.

    The OS will dynamically try to reserve as much heap and stack space as the process needs.