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

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.

主站蜘蛛池模板: 太和县| 拜泉县| 谢通门县| 桐乡市| 收藏| 黄陵县| 安丘市| 芷江| 黑龙江省| 罗平县| 乳山市| 南投市| 青阳县| 施秉县| 汨罗市| 德钦县| 新河县| 甘谷县| 海淀区| 灯塔市| 鹤岗市| 额济纳旗| 天柱县| 通江县| 青海省| 沙湾县| 台北县| 丘北县| 托克逊县| 南华县| 高州市| 博爱县| 永济市| 鲁甸县| 商南县| 澄江县| 无为县| 陈巴尔虎旗| 伊金霍洛旗| 隆德县| 华容县|