官术网_书友最值得收藏!

Deallocation

Unlike when memory is freed up on the stack, when you deallocate memory from the heap, you end up with holes in the heap. These are empty and can be reallocated to other variables. As with anything to do with memory, the reallocation is handled by the OS.

Deallocation is handled automatically by Rust with a style typically called Resource acquisition is initialization. This confusingly named concept means that resources (such as heap memory, but also other things such as file pointers) are allocated during object creation and released during object destruction. Object destruction in Rust happens when the binding goes out of scope. If you need to define custom destructors for your own objects, you can implement the std::ops::Drop() trait. It contains a single method, drop, which gets called when your object loses its last binding.

主站蜘蛛池模板: 随州市| 宁河县| 明星| 镇雄县| 乌鲁木齐县| 尚志市| 慈溪市| 兴和县| 隆子县| 佛冈县| 泌阳县| 财经| 泾阳县| 上饶县| 香港| 稻城县| 诸城市| 玉龙| 凤山市| 阳新县| 韩城市| 北安市| 西林县| 河间市| 泰州市| 乐昌市| 昭苏县| 阿瓦提县| 芜湖市| 南丰县| 克东县| 西林县| 偃师市| 玉田县| 阿巴嘎旗| 密云县| 阿拉善盟| 罗城| 泽库县| 庄浪县| 宁乡县|