1 #include
2 #include
3 #include
4
5 #define ONE_K (1024)
6
7 int main (void)
8 {
9 char *some_memory;
10 int size_to_allocate = ONE_K;
11 int megs_obtained = 0;
12 int ks_obtained = 0;
13
14 while (1)
15 {
16 for (ks_obtained = 0; ks_obtained < 1024;
17 ks_obtained++)
18 {
19 some_memory = (char *) malloc (size_to_allocate);
20 if (some_memory == NULL) exit (EXIT_FAILURE);
21 sprintf (some_memory, "Hello World");
22 }
23 megs_obtained++;
24 printf ("Now allocated %d mbn", megs_obtained);
25 }
26 exit (EXIT_SUCCESS);
27 }