Skip to content

Commit 2621504

Browse files
authored
07_threads: 03_leak: Leak vector with Vec::leak, not Box::leak (mainmatter#107)
1 parent d21c0d1 commit 2621504

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

book/src/07_threads/03_leak.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ run out and crash with an out-of-memory error.
2727
fn oom_trigger() {
2828
loop {
2929
let v: Vec<usize> = Vec::with_capacity(1024);
30-
Box::leak(v);
30+
v.leak();
3131
}
3232
}
3333
```
3434

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

0 commit comments

Comments
 (0)