| |
What is malloc doing, anyway?
malloc uses syscalls to request memory from the kernel, but to avoid expensive repeated syscalls, it allocates memory in larger chunks and manages smaller allocations from that pool—as demonstrated by 1,000 malloc(16) calls requiring only two brk syscalls. A process's address space is divided into regions including text (code), data (initialized variables), BSS (uninitialized variables), heap (malloc), unmapped gap, libraries, and stack, with the program break marking the end of the heap that can be adjusted to grow memory.
Read Full Article →
← More Tech news