Loading

malloc.c

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(void)
  6. {
  7.     unsigned long long required = 33394270208; // 32GB
  8.     char *mem = NULL;
  9.     while (1) {
  10.         printf ("Required %llu\n", required);
  11.         mem = malloc (required);
  12.         if (mem != NULL)
  13.             break;
  14.         required -= 1024 * 1024;
  15.     }
  16.     printf ("Memory size allocated = %llu\n", required);
  17.     memset(mem, 0, required);
  18.     getchar();
  19.     free (mem);
  20.     return 0;
  21. }

Comments