Skip to content

Instantly share code, notes, and snippets.

@mpranj
Created November 6, 2019 12:26
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 mpranj/bbdf00af308ed3f5b3f0f35bc832756f to your computer and use it in GitHub Desktop.
Save mpranj/bbdf00af308ed3f5b3f0f35bc832756f to your computer and use it in GitHub Desktop.
Test memory allocation and free.
/**
* @file
*
* @brief test alloc + free
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main (void)
{
printf ("Entering main.\n");
sleep (10);
int * ptr = calloc (1, 1024 * 1024 * 1024);
printf ("Allocated memory.\n");
sleep (10);
ptr[0] = 42;
printf ("Used memory.\n");
sleep (10);
free (ptr);
printf ("Freed memory.\n");
sleep (60);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment