Skip to content

Instantly share code, notes, and snippets.

@Juma7C9
Created May 11, 2016 21:12
Show Gist options
  • Save Juma7C9/84553d367bb6175a6fadbb0198a45412 to your computer and use it in GitHub Desktop.
Save Juma7C9/84553d367bb6175a6fadbb0198a45412 to your computer and use it in GitHub Desktop.
/* Simple program to test memory allocation - goes on until killed */
#include "stdlib.h"
#include "stdio.h"
#define _256M 64*1024*1024
int* p;
int i=0, j;
int main(){
do{
p=malloc(_256M*sizeof(int));
for(j=0; j<_256M; j++){
*(p+j) = i+j;
}
printf("allocated %d MiB\n", i+=256);
} while ( p!= NULL );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment