How malloc() and sbrk() works in unix?

前端 未结 4 800
别跟我提以往
别跟我提以往 2021-02-13 10:58

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()

4条回答
  •  既然无缘
    2021-02-13 11:52

    sbrk() function increases the programs data segment allocation by specified bytes.

    malloc(4096); // sbrk += 4096 Bytes
    free();       // freeing memory will not bring down the sbrk by 4096 Bytes  
    malloc(4096); // malloc'ing again will not increase the sbrk and it will use 
                     the existing space which not result in sbrk() call.  
    

提交回复
热议问题