How are malloc and free implemented?

后端 未结 6 1021
心在旅途
心在旅途 2020-12-16 00:42

I want to implement my own dynamic memory management system in order to add new features that help to manage memory in C++.

I use Windows (XP) and Linux (Ubuntu). Wh

6条回答
  •  孤城傲影
    2020-12-16 01:17

    brk is the system call used on Linux to implement malloc and free. Try the man page for information.

    You've got the Windows stuff down already.

    Seeing the other answers here, I would like to note that you are probably reinventing the wheel; there are many good malloc implementations out there already. But programming malloc is a good thought exercise - take a look here for a nice homework assignment (originally CMU code) implementing the same. Their shell gives you a bit more than the Linux OS actually does, though :-).

提交回复
热议问题