Last active
August 29, 2015 14:07
-
-
Save fclairamb/c2436397f7517b22be4b to your computer and use it in GitHub Desktop.
Change OOM priority score
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
#ifdef SHELL | |
gcc -Wall -Werror $0 && ./a.out | |
exit $? | |
#endif | |
#include <stdio.h> | |
void change_oom_score(int oom_adj) { | |
FILE * fp = fopen("/proc/self/oom_adj", "w"); // Old one (SK20) | |
if ( ! fp ) fp = fopen("/proc/self/oom_score_adj", "w"); // New one | |
if ( fp ) { | |
fprintf(fp, "%d", oom_adj); | |
fclose( fp ); | |
} | |
} | |
int main() { | |
change_oom_score( 3 ); // It's already really high | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment