diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-08-05 08:53:21 +0200 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-08-05 08:53:21 +0200 |
commit | 295b343aecf330e830d79f06e0efc511e7d76da1 (patch) | |
tree | 85057ef1fe401adcd0d958ddf6ff966f25d8fef0 /Variables lives in the stack.md | |
parent | f43372529e655f3b039946c969e4465193eb2042 (diff) |
vault backup: 2025-08-05 08:53:21
Diffstat (limited to 'Variables lives in the stack.md')
-rw-r--r-- | Variables lives in the stack.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Variables lives in the stack.md b/Variables lives in the stack.md new file mode 100644 index 0000000..a929a67 --- /dev/null +++ b/Variables lives in the stack.md @@ -0,0 +1,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.
\ No newline at end of file |