There are many articles about the use of Linux under the heap, which I have summed up before, but not in-depth investigation. This time from the source to analyze why it is used, how to be used. The so-called source is the heap management mechanism, in more detail is the MALLC () and the free () function in libc.so.
Directory
The meaning of the existence of the 0x0 heap the existence of the heap management function
of the 0x0 heap is found
First, the heap mechanism, the white heap is just a user-state memory management mechanism. Heap management mechanism is set up to improve the efficiency of memory usage, if there is no heap can you? Of course, it is possible to allocate memory every time you need to use mmap (or similar function kernel operation) in the virtual address space, each time you need to allocate back to release. I have not studied the memory management mechanism in the kernel of Linux, but for Windows it can be summed up like this: Windows uses VAD to describe a process's virtual address space, VAD is a tree-like data structure, Each time a memory is allocated, a node that is attached to the Vad tree represents this block of user-State address space has been allocated, so if there is no heap mechanism, every time to allocate memory to operate the VAD tree. This is very inefficient, VAD is the structure of the kernel, is attached to the eprocess of the corresponding process, want to learn more about the Windows Kernel memory management can be seen in the Windows Kernel scenario analysis book. In addition, many concrete implementations of the heap are different, and can even implement their own heap management mechanism functions.
0x1 found heap management function
To find the heap management function, first find the libc.so library used. Libc.so is the standard C function library, and the C library is no use for Windows. But for Linux systems, the C function library even corresponds to the underlying call.
See Heap overflow--malloc and free from source