Skip to content

Commit

Permalink
07_threads: 03_leak: Leak vector with Vec::leak, not Box::leak (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenefil authored Jun 30, 2024
1 parent de45f8a commit fccad08
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions book/src/07_threads/03_leak.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ run out and crash with an out-of-memory error.
fn oom_trigger() {
loop {
let v: Vec<usize> = Vec::with_capacity(1024);
Box::leak(v);
v.leak();
}
}
```

At the same time, memory leaked via `Box::leak` is not truly forgotten.\
At the same time, memory leaked via `leak` method is not truly forgotten.\
The operating system can map each memory region to the process responsible for it.
When the process exits, the operating system will reclaim that memory.

Expand Down

0 comments on commit fccad08

Please sign in to comment.