Force free() to return malloc memory back to OS

前端 未结 2 1232
梦毁少年i
梦毁少年i 2020-11-27 08:12

Seems like even after I free all the memory for a Linux process that was allocated by malloc(), memory is still reserved for the process and not returned to the

2条回答
  •  渐次进展
    2020-11-27 08:56

    The only reliable and portable way to have the OS reclaim memory is to exit the process and restart it again, restoring any state you need to continue.

    Of course, writing your own malloc/free implementation using brk/sbrk according to your needs is the other option.

提交回复
热议问题