Skip to content

Instantly share code, notes, and snippets.

@krishnan793
Last active May 3, 2017 16:49
Show Gist options
  • Save krishnan793/e8caf6f5cb314b340994 to your computer and use it in GitHub Desktop.
Save krishnan793/e8caf6f5cb314b340994 to your computer and use it in GitHub Desktop.
Use the entire RAM space using dynamic memory allocation. Will also display the memory it is using.
#include<stdio.h>
#include<stdlib.h>
/*Struct flood require 256*4=1Kb */
struct flood{
long int a[256];
}*temp;
void main()
{
long int k=sizeof(struct flood);
while(1)
{
temp=(struct flood *)malloc(sizeof(struct flood));
printf("%0.2f Mb\n",(float)k/(1024*1024));
k=k+1024;
if(temp==NULL)
printf("Memory Full\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment