workshit/src/reaper.c

31 lines
523 B
C
Raw Normal View History

2015-06-06 02:11:44 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define AMOUNT 1024*1024*1024
void * mem[16];
int main() {
2015-06-12 19:53:18 +00:00
int i;
for(i=0; i < 16; i++) {
mem[i] = malloc(AMOUNT); // One gigabyte XXX do not do this
memset(mem[i], 0, AMOUNT);
printf("Allocated %d GB of ram...\n", i+1);
}
2015-06-06 02:11:44 +00:00
2015-06-12 19:53:18 +00:00
printf("16 GB of memory used, waiting for input... ");
2015-06-06 02:11:44 +00:00
2015-06-12 19:53:18 +00:00
while(1) {
printf("Trashing ram use...\n");
2015-06-06 02:11:44 +00:00
2015-06-12 19:53:18 +00:00
for(i=0; i < 16; i++) {
memcpy(mem[i], mem[(i+1)%16], AMOUNT);
}
}
for (i=0; i < 16; i++) {
free(mem[i]);
}
}