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

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.

主站蜘蛛池模板: 米林县| 金寨县| 凤台县| 大姚县| 阿合奇县| 定结县| 邵武市| 买车| 陈巴尔虎旗| 合山市| 襄樊市| 法库县| 祥云县| 二连浩特市| 克拉玛依市| 九龙城区| 巫溪县| 光泽县| 措勤县| 肃北| 宿州市| 明光市| 波密县| 曲周县| 西吉县| 江都市| 恩平市| 侯马市| 吉木乃县| 化隆| 五常市| 微山县| 衢州市| 乐平市| 黄山市| 新闻| 洪湖市| 龙口市| 武穴市| 利津县| SHOW|