Created
January 17, 2011 07:41
-
-
Save d6rkaiz/782593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
int main(int argc, char** argv) { | |
int max = -1; | |
int mb = 0; | |
char* buffer; | |
if(argc > 1) | |
max = atoi(argv[1]); | |
while((buffer=malloc(1024*1024)) != NULL && mb != max) { | |
memset(buffer, 0, 1024*1024); | |
mb++; | |
printf("Allocated %d MB\n", mb); | |
sleep(1); | |
} | |
printf("Memory Allocate Error\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment