-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathram_stress.c
More file actions
37 lines (30 loc) · 912 Bytes
/
Copy pathram_stress.c
File metadata and controls
37 lines (30 loc) · 912 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
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define ALLOC_MB 100
#define ITERATIONS 100
int main() {
void **allocated_blocks = malloc(sizeof(void *) * ITERATIONS);
if (!allocated_blocks) {
printf("Failed to allocate tracking array\n");
return 1;
}
for (int i = 0; i < ITERATIONS; i++) {
size_t alloc_size = ALLOC_MB * 1024 * 1024;
allocated_blocks[i] = malloc(alloc_size);
if (!allocated_blocks[i]) {
printf("Failed to allocate %d MB\n", (i + 1) * ALLOC_MB);
break;
}
// 실제로 메모리에 write → compressed memory 회피
memset(allocated_blocks[i], i, alloc_size);
printf("Allocated %d MB total\n", (i + 1) * ALLOC_MB);
sleep(1);
}
printf("Sleeping... press Ctrl+C to exit\n");
while (1) {
sleep(10);
}
return 0;
}