Files
cfunny/main.c
T
2026-05-30 00:12:38 +02:00

37 lines
693 B
C

#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#define sleep_ms(ms) Sleep(ms)
#else
#include <unistd.h>
#define sleep_ms(ms) usleep((ms) * 1000)
#endif
int MyNum;
int times_iterated;
int main() {
const size_t CHUNK_SIZE = 500 * 1024 * 1024;
size_t total = 0;
while (1) {
void *chunk = malloc(CHUNK_SIZE);
if (!chunk) {
printf("Malloc failed at %zuMB\n", total / 1024 / 1024);
break;
}
memset(chunk, 0xAA, CHUNK_SIZE);
total += CHUNK_SIZE;
printf("Allocated: %zuMB\n", total / 1024 / 1024);
sleep_ms(500);
}
return 0;
}