Skip to content

Commit 9f3a397

Browse files
authored
A rust implementation (#56)
智能指针转裸指针故意不回收, 无限循环, 直接跟他爆了!
1 parent 296b9ee commit 9f3a397

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

DrEden33773/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Amazing-OOM-RS
2+
3+
## Introduction
4+
5+
An extremely short executable rust implementation to f\*\*k the memory up.
6+
7+
## Code
8+
9+
```rust
10+
fn main(){loop{Box::leak(0.into());}}
11+
```
12+
13+
## Reason
14+
15+
1. `0.into()` simply generates a unique pointer with a clean ownership
16+
2. `Box::leak()` simply forgets the input unique pointer's ownership, turning it into a raw pointer
17+
3. Each time you leak a unique pointer, you don't give a try to free/drop it's load on heap memory
18+
4. `loop{}` means this program will continue to be executed until all of the memory have been f\*\*ked up

DrEden33773/htop.png

3.07 MB
Loading

DrEden33773/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main(){loop{Box::leak(0.into());}}

0 commit comments

Comments
 (0)