Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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;
- }
Add Comment
Please, Sign In to add comment