- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 154字
- 2021-07-02 23:07:26
The stack frame
The stack frame is a term you may have come across. It is the amount of memory allocated to a function, which is used to store all of the local variables and function parameters. In the following snippet, the stack frame will be large enough to store the two int values and the single float32 type:
fn main() { let a = 10; let b = 20; let pi = 3.14f32; }
Once main has exited, the stack frame allocated on entry will be released. The beauty of both the allocation and deallocation is that they are carried out without the user needing to do anything. The amount of memory can also be computed ahead of time, as the compiler knows which local variables are in use. This, again, gives a speed increase.
For every positive, there is a downside: the values stored only exist for the lifetime of the method.
推薦閱讀
- C++程序設(shè)計(jì)教程
- Java程序設(shè)計(jì)與開發(fā)
- Intel Galileo Essentials
- C語言程序設(shè)計(jì)案例教程(第2版)
- 自己動(dòng)手實(shí)現(xiàn)Lua:虛擬機(jī)、編譯器和標(biāo)準(zhǔn)庫
- Python數(shù)據(jù)可視化:基于Bokeh的可視化繪圖
- 深入淺出WPF
- 編程珠璣(續(xù))
- Data Analysis with IBM SPSS Statistics
- Windows Server 2012 Unified Remote Access Planning and Deployment
- NoSQL數(shù)據(jù)庫原理
- Mobile Device Exploitation Cookbook
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- Android Development Tools for Eclipse
- ANSYS FLUENT 16.0超級學(xué)習(xí)手冊