Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* $Id: malloc.c 1428 2010-09-28 11:02:37Z santi $ */
- main() {
- int n = 0;
- char *buffer;
- while(1) {
- n++;
- printf ("%d MB\n", n);
- buffer = (char *) malloc(n * 1024 * 1024);
- if (buffer == NULL) {
- printf("Limite de memoria alcanzado para malloc() => %d MB\n", n);
- exit(-1);
- }
- // memset(buffer, 0, n * 1024 * 1024);
- free(buffer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment