From 0cf4c4025a12eeb983f2f818efb2f480abc21313 Mon Sep 17 00:00:00 2001 From: hjp Date: Thu, 3 Feb 2000 23:49:45 +0000 Subject: [PATCH] *** empty log message *** --- hogs/memhog.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 hogs/memhog.c diff --git a/hogs/memhog.c b/hogs/memhog.c new file mode 100644 index 0000000..0aa5d0c --- /dev/null +++ b/hogs/memhog.c @@ -0,0 +1,22 @@ +#include +#include +int main(void) { + size_t s = 0x100000; + size_t sum = 0; + + while (s) { + void *p; + if (p = malloc(s)) { + sum += s; + printf("%lu - %lu\n", + (unsigned long)s, + (unsigned long)sum); + sleep (1); + memset(p, 'a', s); + s *= 2; + } else { + s /= 2; + } + } + return 0; +}