Guest User

Untitled

a guest
Sep 28th, 2010
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* $Id: malloc.c 1428 2010-09-28 11:02:37Z santi $ */
  5.  
  6. main() {
  7.         int n = 0;
  8.         char *buffer;
  9.  
  10.         while(1) {
  11.                 n++;
  12.                 printf ("%d MB\n", n);
  13.                 buffer = (char *) malloc(n * 1024 * 1024);
  14.  
  15.                 if (buffer == NULL) {
  16.                         printf("Limite de memoria alcanzado para malloc() => %d MB\n", n);
  17.                         exit(-1);
  18.                 }
  19.  
  20.                 // memset(buffer, 0, n * 1024 * 1024);
  21.                 free(buffer);
  22.         }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment