How does sbrk() work in C++?

前端 未结 5 1736
感情败类
感情败类 2020-12-15 00:07

Where can I read about sbrk() in some detail?

How does it exactly work?

In what situations would I want to use sbrk() instead of th

5条回答
  •  感情败类
    2020-12-15 00:46

    sbrk is pretty much obsolete, these days you'd use mmap to map some pages out of /dev/zero. It certainly isn't something you use instead of malloc and friends, it's more a way of implementing those. Also, of course, it exists only on posix-based operating systems that care about backwards compatibility to ancient code.

    If you find Malloc and New too cumbersome, you should look into garbage collection instead... but beware, there is a potential performance cost to that, so you need to understand what you are doing.

提交回复
热议问题