图解 Linux 内存管理:malloc 一块内存,内核背后做了什么?-51CTO. COM 写 C C++ 的人每天都在用 malloc,但很少有人认真想过: 这一块内存,内核是怎么给你的? 物理内存那么大一块,怎么分给成千上万个进程用?为什么频繁 malloc free 会产生内存碎片?slab 分配器又是什么?服务器有几十个 CPU、几百 GB 内存,NUMA 架构对性能有什么影响? 这篇文章,从物理内存的管理讲
malloc - cppreference. com If size is zero, the behavior of malloc is implementation-defined For example, a null pointer may be returned Alternatively, a non-null pointer may be returned; but such a pointer should not be dereferenced, and should be passed to free to avoid memory leaks