Does malloc allocate a block of memory on the heap or should it be called Virtual Address Space?
Am I being picky calling it Virtual Address Space or this just the legac
malloc()
does allocate a block of memory on the HEAP.
Should it be called virtual address space? Hold that thought for a second. VAS (virtual address space) is a memory mapping mechanism that comprises the entire memory space of an application. In other words, VAS is not restricted to the memory area of the HEAP. The HEAP is actually just another part of it.
Each time a new application is run, the OS creates a new process and allocates a new VAS for the application. Memory allocated through malloc()
is reserved on the HEAP, which is a special memory region within the VAS, as you know, and memory allocated through standard means ends up in the stack, which is another region of memory located inside the VAS of the application.