-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmempig.c
More file actions
27 lines (25 loc) · 692 Bytes
/
mempig.c
File metadata and controls
27 lines (25 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <malloc.h>
int main() {
FILE* oom_score_adj = fopen("/proc/self/oom_score_adj","w");
if(oom_score_adj) {
fprintf(oom_score_adj,"1000\n");
fclose(oom_score_adj);
} else {
FILE* oom_adj = fopen("/proc/self/oom_adj","w");
if(oom_adj) {
fprintf(oom_adj,"15\n");
fclose(oom_adj);
} else {
fprintf(stderr, "Failed to raise OOM score\n");
fprintf(stderr, "Are you fast enough to ^C before the havoc begins?\n");
}
}
for(;;) {
char* c=malloc(655360);
int i;
for(i=0;i<655360;++i) {
c[i]=0;
}
}
}