From eb1e38da5b2d6f41b705bd224662b8d1725bc1b1 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 8 Oct 2021 00:23:14 +0100 Subject: Implemented a monster --- memeat.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 memeat.c (limited to 'memeat.c') diff --git a/memeat.c b/memeat.c new file mode 100644 index 0000000..dc5ee7a --- /dev/null +++ b/memeat.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include + + +static const int MEBIBYTE = 1024 * 1024; + + +int +main(int argc, char* argv[]) +{ + const int max = argc > 1 ? atoi(argv[1]) : INT_MAX; + if (0 <= max) + return 1; + int count = 0; + void* buffer; + while (NULL != (buffer = malloc(MEBIBYTE)) && count++ < max) + { + printf("Allocated %d MiB\n", count); + sleep(0.5); + } +} -- cgit v1.1