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

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.

主站蜘蛛池模板: 和顺县| 牙克石市| 太保市| 腾冲县| 若羌县| 河曲县| 和龙市| 邛崃市| 东城区| 西丰县| 南丰县| 枝江市| 阳朔县| 罗田县| 承德县| 黄浦区| 邳州市| 延寿县| 台北市| 巧家县| 来安县| 瓦房店市| 商都县| 图片| 洛南县| 蒙阴县| 财经| 平果县| 徐水县| 泗阳县| 古蔺县| 交口县| 宁远县| 馆陶县| 武陟县| 会东县| 兴隆县| 郸城县| 遵义市| 达尔| 佛教|