Skip to content

Instantly share code, notes, and snippets.

@dijit
Created January 6, 2019 22:47
Show Gist options
  • Save dijit/cb2caa1a40d48e03613f5af0e518d626 to your computer and use it in GitHub Desktop.
Save dijit/cb2caa1a40d48e03613f5af0e518d626 to your computer and use it in GitHub Desktop.
#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