79
On Linux if I were to malloc(1024 * 1024 * 1024), what does malloc actually do?
I'm sure it assigns a virtual address to the allocation (by walking the free list and creating a new mapping if necessary), but does it actually create 1 GiB worth of swap pages? Or does it mprotect the address range and create the pages when you actually touch them like mmap does?
(I'm specifying Linux because the standard is silent on these kinds of details, but I'd be interested to know what other platforms do as well.)