Is free() zeroing out memory?

后端 未结 7 1550
庸人自扰
庸人自扰 2020-12-03 06:24

Until today I lived in belief that calling free() on memory space releases it for further allocation without any other modifications. Especially, considering th

7条回答
  •  渐次进展
    2020-12-03 07:12

    free() can actually return memory to the operating system and make the process smaller. Usually, all it can do is allow a later call to malloc to reuse the space. In the meantime, the space remains in your program as part of a free-list used internally by malloc.

提交回复
热议问题