3 ms·
brk/sbrk are obsolete legacy functions. Memory allocated with mmap is released with munmap. brk/sbrk can increase the size of the data segment, thus allocatin
by adrian_b 4y ago
brk/sbrk are obsolete legacy functions.
Memory allocated with mmap is released with munmap.
brk/sbrk can increase the size of the data segment, thus allocating memory, but they can also decrease the size of the data segment, freeing the memory.
Whether calling the function free of the standard C library results sometimes in also invoking munmap or brk/sbrk to release memory to the operating system is obviously implementation dependent.
When malloc/free are bypassed and you get memory from the OS directly with mmap, to be used by a custom memory allocator, e.g. an arena allocator, then it is up to you to call munmap when the memory is no longer needed.