且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

free()无法正确释放内存?

更新时间:2023-02-02 16:32:06

free()通常不会更改程序中的任何值-只是对C运行时堆进行调整.这意味着将保留刚刚释放的内存中的值.但是,尝试从您的代码访问它们会导致未定义的行为.

free() does not normally change any values in your program - it just makes adjustments to the C runtime heap. This means that the values in the memory that was just freed are retained. However, attempts to access them from your code lead to undefined behaviour.