???????????糿6?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????磬??????糿5????????????????????????????Plumbr????????????
 

??????????????????????????????????????????????????????????????????????????????????????????????????????????ó??????????????????????????С???ó??????????д?????о??棬?????κο?????????
????????????????????????????????????????????????????????????????????????????????????????????30?????????/var/log/kern.log????з???????????????
????Jun  4 07:41:59 plumbr kernel: [70667120.897649] Out of memory: Kill process 29957 (java) score 366 or sacrifice child
????Jun  4 07:41:59 plumbr kernel: [70667120.897701] Killed process 29957 (java) total-vm:2532680kB?? anon-rss:1416508kB?? filers:0kB
???????????????Linux?????????????????Linux?????????а???????????????????????Щ???????????????????????????????е??????????????е????Linux????ж??????????治????????Out of memory Killer?? OOM Killer?????????????????????????£???????????????????????????????????????????????????????????????????????????????????????????????????н?????????????????????????????
???????“Out of memory killer”
???????????£?Linux??????????????????泬?????????????С????????????????????????????????????????????????????з??????????棨??????????????????????????????????????????????????????????????100Mb????????????????????????????????????????????????????????????????????????????????????10Gb??????????????????100?????????????????100????????????????ó????10G/100M????
????????????????????????????????????????????????????????????????·?????????μ???????????????????????????????????????????????????????????????root???????????????????????????????????????????????????????????????????
????????”Out of memory killer”???????????????ο???????????
?????????????Out of memory killer??
?????????????????????????????????????????????????????????????????糿5???????????????????????????????
????/proc/sys/vm/overcommit_memory?е???????????????????——????????1??????ζ?????malloc()??????????
??????ó???????????EC2 m1.small????????EC2?????????????????????????
???????????????????????????????????????????壬???????ó???????????Щ????????????????????????檔??泬??????????????????????????????????棬??????????治?????????????????????????????????????????????????????????????
???????
??????????????????????????????????λ????????ú???????????д???С????????????????????????????????Linux?±????????????????????Σ????????μ??????Ubuntu?????е????
????package eu.plumbr.demo;
????public class OOM {
????public static void main(String[] args){
????java.util.List l = new java.util.ArrayList();
????for (int i = 10000; i < 100000; i++) {
????try {
????l.add(new int[100_000_000]);
????} catch (Throwable t) {
????t.printStackTrace();
????}
????}
????}
????}
???????????????????? Out of memory: Kill process (java) score or sacrifice child?????
????????????????????????????????????С??????????????????У??????-Xm2g??????2G??С??????????????????????μ??????
????swapoff -a
????dd if=/dev/zero of=swapfile bs=1024 count=655360
????mkswap swapfile
????swapon swapfile
?????????????
????????????кü?????????????????????????У?????????????????????????????????????????????????????????????????????????????????????????????????JVM???GC??????????????μ??????????????????????????????
???????б???Щ????????OOM killer??????????????????????????С??????????????????ó??????????????