Created
November 6, 2019 12:26
-
-
Save mpranj/bbdf00af308ed3f5b3f0f35bc832756f to your computer and use it in GitHub Desktop.
Test memory allocation and free.
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
/** | |
* @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