ã¡ã¢ãªãªã¼ãã¼ã³ããã
Linuxã®ã話ã
å¤ãã®ããã°ã©ã ã¯ã使ããã©ããåãããªããã©åãæ¢ããå¤ãã«ã¡ã¢ãªã確ä¿ãã¦ãããã¨ãããããã¾ãã
ãããã£ãããã°ã©ã ãå¤æ°åãã¦ããã¨ãã·ã¹ãã å
¨ä½ã®ã¡ã¢ãªä»æ§å¹çãæªããªã£ã¦ãã¾ãã¾ãã
Linuxã«ã¯ã¡ã¢ãªãªã¼ãã¼ã³ãããã¨ããæ©æ§ããããå®ã¡ã¢ãªä»¥ä¸ã®ã¡ã¢ãªãå²ãå½ã¦ããã¨ãå¯è½ã§ãã
ã¡ã¢ãªã確ä¿ããéã«ã¯ã沢山ããããã«è¦ãããã¦ãããå®éã«ä½¿ããã段éã§ã¡ã¢ãªãå²ãå½ã¦ãããã«ãªã£ã¦ãã¾ãã
ã¡ã¢ãªãªã¼ãã¼ã³ããããããã¨ãåãæ¢ããã¡ã¢ãªã§å¤±æãããã¨ãã»ã¼ç¡ããªãã¾ãã
mallocã®å¾ã«ç¢ºä¿ãã§ãããã©ãããã§ãã¯ãã¦ããªãæ§ãªããã°ã©ã ã§ã確ä¿ã«å¤±æãã¦ä¾å¤ã§è½ã¡ããããªãã¨ã¯ç¡ãããã§ãã
å®éã«å®ã¡ã¢ãªãä»®æ³ã¡ã¢ãªã足ããªããªã£ãã¨ãã«ã¯ãOOM Killerã¨ããæ©æ§ãçºåãã¾ãã
ã«ã¼ãã«ãã¡ã¢ãªãåå確ä¿ã§ããããªããã»ã¹ãé¸ã³ãããã»ã¹ãå¼·å¶çµäºããã¦ç©ºãã¡ã¢ãªã¼ã確ä¿ãã¾ãã
OOM Killerãçºåããã¨ãçµäºãããããå´ã®ããã»ã¹ã¯æå³ããªãçç±ã§çµäºããããã¨ã«ãªãã¾ãã
ããå æ¸ãªããã°ã©ã ãæ´»ããã¦ãã¾ã¨ããªããã°ã©ã ãå·»ãæ·»ãã§æ®ºãã¦ãã¾ãã¨ããããªãã¨ãè¿·æãªæ©æ§ã§ãã
å®å®åä½ã®çºã«ã¯OOM Killerãçºåããªãããã«è¨å®ããã»ããããã§ãããã
OOM Killerã®åªå é ä½ãå¤æ´ãã
åªå é ä½ã-16ã15ã¾ã§ã®å¤ã§æ¸ãè¾¼ã¿ã¾ããä½ãå¤ã»ã©OOM Killterã®å¯¾è±¡ã¨ãªã確çãä½ããªãã¾ãã
echo (åªå é ä½) > /proc/(Process ID)/oom_adj
oom_adjã-17ã«ãããã¨ã§OOM Killerã®å¯¾è±¡ããå¤ããã¨ãã§ãã¾ãã
echo -17 > /proc/(Process ID)/oom_adj
ã¡ã¢ãªãªã¼ãã¼ã³ãããã使ç¨ããªã
vm.overcommit_memoryã2ã«è¨å®ãããã¨ã§ãOOM Killerã®åå ã¨ãªãã¡ã¢ãªãªã¼ãã¼ã³ããããç¡å¹ã«ãããã¨ãã§ãã¾ãã
# sysctl -w vm.overcommit_ratio=99 # sysctl -w vm.overcommit_memory=2
/etc/sysctl.confã«è¨è¼ãããã¨ã§èµ·åæããæå¹ã«ãªãã¾ãã
vm.overcommit_ratio=99 vm.overcommit_memory=2