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
is a library call. On linux, it in turn calls sbrk
system call. sbrk
will increase the size of heap but does not actually allocate physical memory. When the process tries to access this address, a page fault
is raised and then at that time kernel allocates actual physical page and maps to the virtual address.
TL;DR: malloc
returns a virtual address and does NOT allocate physical memory.
Check this out.