/* CSE 303, Spring 2009, Marty Stepp This program figures out the approximate size of the heap by repeatedly allocating heap memory (malloc) until the allocation fails. */ #include #include int main(void) { int count = 0; void *p; // loop will end when p is 0, i.e., when malloc returns NULL while (p) { p = malloc(1024 * 1024); count++; printf("%d mb allocated\n", count); } return 0; }