mirror of
https://github.com/mainmatter/100-exercises-to-learn-rust
synced 2024-11-16 19:50:44 +01:00
07_threads: 03_leak: Leak vector with Vec::leak, not Box::leak (#107)
This commit is contained in:
parent
de45f8adf2
commit
fccad08921
1 changed files with 2 additions and 2 deletions
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in a new issue