Skip to content

Instantly share code, notes, and snippets.

@d6rkaiz
Created January 17, 2011 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d6rkaiz/782593 to your computer and use it in GitHub Desktop.
Save d6rkaiz/782593 to your computer and use it in GitHub Desktop.
#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