- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 138字
- 2021-07-02 23:07:26
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.
- 多媒體CAI課件設計與制作導論(第二版)
- INSTANT OpenCV Starter
- Java Web應用開發技術與案例教程(第2版)
- Android 應用案例開發大全(第3版)
- C++反匯編與逆向分析技術揭秘(第2版)
- Mastering Python Design Patterns
- 實戰Java高并發程序設計(第2版)
- 算法設計與分析:基于C++編程語言的描述
- Mastering JavaScript
- 軟件測試分析與實踐
- Flink核心技術:源碼剖析與特性開發
- Vue.js 3.x高效前端開發(視頻教學版)
- Building a Media Center with Raspberry Pi
- Microsoft Dynamics GP 2013 Cookbook
- RESTful Web API Design with Node.js(Second Edition)