Created
January 6, 2019 22:47
-
-
Save dijit/cb2caa1a40d48e03613f5af0e518d626 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 <stdio.h> | |
#include <stdlib.h> | |
int try_allocate(int i){ | |
int *ptr; | |
ptr = (int*) malloc(i); | |
if (ptr==0) { | |
printf("FAILED TO ALLOCATE"); | |
return 1; | |
} | |
return 0; | |
} | |
int main() { | |
int x,result; | |
for (x=1; x != 256; x++) { | |
// 1G | |
result = try_allocate((1024*1024)*1024); | |
if(result != 0) { | |
printf("Failed"); | |
return 1; | |
} | |
printf("Allocated %iGB\n", x); | |
sleep(1); | |
} | |
sleep(360); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment