I am new to UNIX, and I am studying some of UNIX system calls such as brk()
, sbrk()
, and so on....
Last day I have read about malloc()
why malloc reduces the number of sbrk() system calls that the program must perform?
say, if you call malloc() to request 10 bytes memory, the implementation may use sbrk (or other system call like mmap) to request 4K bytes from OS. Then when you call malloc() next time to request another 10 bytes, it doesn't have to issue system call; it may just return some memory allocated by system call of the last time 4K.