Does malloc() use brk() or mmap()?

后端 未结 3 1806
一生所求
一生所求 2020-12-05 07:19

c code:

// program break mechanism
// TLPI exercise 7-1

#include 
#include 

void program_break_test() {
    printf(\"%10p\\n         


        
3条回答
  •  忘掉有多难
    2020-12-05 07:54

    malloc is not limited to using sbrk to allocate memory. It might, for example, use mmap to map a large MAP_ANONYMOUS block of memory; normally mmap will assign a virtual address well away from the data segment.

    There are other possibilities, too. In particular, malloc, being a core part of the standard library, is not itself limited to standard library functions; it can make use of operating-system-specific interfaces.

提交回复
热议问题