Grokking Operating Systems and Networking for Backend Engineers
0% completed
The Heap, the Stack and Memory Mapped Files
A C program asks for 64 KB with malloc, and then for 1 MB. strace shows that the two requests reach the kernel in different ways. The small one moves the end of an existing region with a system call named brk, and the large one creates a new region with mmap. When the program frees both blocks, only the large one goes back to the kernel.
This page explains where a process's memory comes from: the heap, the stacks of its threads, and the files and blocks it maps. Each kind is created in its own way, and each fails in its own way in production.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%