summaryrefslogtreecommitdiff
path: root/Variables lives in the stack.md
blob: a929a6717f652142a2d21fbe50dc6e49d72deb14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[[Rust]]
[[Boxes live in the heap]]


---

The stack consists of frames.

Frames are just mappings of names to values within a single scope, they are tightly coupled to a specific function

Freeing is the act of discarding such a frame.

If we assign a variable such as 
```rust
let a = [0; 1_000_000];
let b = a;
```

the value of a is **copied** to b (thus we get two huge arrays). This is **expensive**. Think about what happens when we call a function.