Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char** argv) {
  5. //note: no need for this if we turn off overcommitting below
  6. //man proc
  7. //can change oom 'badness' rating this way
  8. // /proc/[pid]/oom_score -- write to this file as root
  9. //negatives make it less likely to kill, positives make it more
  10.  
  11. //we can make the kernel not overcommit by setting
  12. ///proc/sys/vm/overcommit_memory to 2
  13.  
  14. while(1) {
  15. unsigned int *all_the_memory = malloc(sizeof(int));
  16. if(all_the_memory == NULL) {
  17. printf("failed\n");
  18. return -1;
  19. }
  20.  
  21. *all_the_memory = 420;
  22. printf("mem was: %p\n", all_the_memory);
  23. fflush(stdout);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement