Created
March 30, 2012 17:39
-
-
Save nelhage/2253262 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdlib.h> | |
#include <stdio.h> | |
#define NALLOC (1 << 10) | |
#define ALLOCSZ (1 << 12) | |
int main(void) { | |
void *buffers[NALLOC]; | |
int i; | |
char cmdline[1024]; | |
snprintf(cmdline, sizeof(cmdline), "ps --no-headers -o rss %d", getpid()); | |
for (i = 0; i < NALLOC; i++) | |
buffers[i] = malloc(ALLOCSZ); | |
printf("Allocated memory...\n"); | |
system(cmdline); | |
malloc(10); | |
for (i = 0; i < NALLOC; i++) | |
free(buffers[i]); | |
printf("Freed memory...\n"); | |
system(cmdline); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment