Guest User

Untitled

a guest
Sep 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. #define NALLOC (1 << 10)
  5. #define ALLOCSZ (1 << 12)
  6.  
  7. int main(void) {
  8. void *buffers[NALLOC];
  9. int i;
  10.  
  11. char cmdline[1024];
  12. snprintf(cmdline, sizeof(cmdline), "ps --no-headers -o rss %d", getpid());
  13.  
  14. for (i = 0; i < NALLOC; i++)
  15. buffers[i] = malloc(ALLOCSZ);
  16.  
  17. printf("Allocated memory...\n");
  18. system(cmdline);
  19.  
  20. malloc(10);
  21.  
  22. for (i = 0; i < NALLOC; i++)
  23. free(buffers[i]);
  24.  
  25. printf("Freed memory...\n");
  26. system(cmdline);
  27.  
  28. return 0;
  29. }
Add Comment
Please, Sign In to add comment