34.Out of memory Kill process导致系统崩溃和kill进程

一:错误打印:
1.关键打印:

app.out invoked oom-killer: gfp_mask=0x200da, order=0, oom_adj=0, oom_score_adj=0
Out of memory: Kill process 957 (app.out) score 524 or sacrifice child
Killed process 957 (app.out) total-vm:67472kB, anon-rss:14496kB, file-rss:516kB

2.全部打印:

app.out invoked oom-killer: gfp_mask=0x200da, order=0, oom_adj=0, oom_score_adj=0
Backtrace: 
[<c000cfc4>] (dump_backtrace+0x0/0x10c) from [<c03990b4>] (dump_stack+0x18/0x1c)
 r6:00000000 r5:0000020c r4:c045f06c r3:c04e2080
[<c039909c>] (dump_stack+0x0/0x1c) from [<c03999c4>] (dump_header.isra.16+0x54/0x150)
[<c0399970>] (dump_header.isra.16+0x0/0x150) from [<c0399b08>] (oom_kill_process.part.19.constprop.23+0x48/0x220)
 r6:00000000 r5:0000020c r4:c045f06c
[<c0399ac0>] (oom_kill_process.part.19.constprop.23+0x0/0x220) from [<c0062a94>] (out_of_memory+0x2e8/0x32c)
[<c00627ac>] (out_of_memory+0x0/0x32c) from [<c0065f88>] (__alloc_pages_nodemask+0x67c/0x6ac)
[<c006590c>] (__alloc_pages_nodemask+0x0/0x6ac) from [<c007abac>] (handle_pte_fault+0x4d8/0x610)
[<c007a6d4>] (handle_pte_fault+0x0/0x610) from [<c007ad68>] (handle_mm_fault+0x84/0xb8)
[<c007ace4>] (handle_mm_fault+0x0/0xb8) from [<c000fdc4>] (do_page_fault+0x16c/0x280)
[<c000fc58>] (do_page_fault+0x0/0x280) from [<c00085e0>] (do_DataAbort+0x3c/0xa0)
[<c00085a4>] (do_DataAbort+0x0/0xa0) from [<c00091a0>] (__dabt_usr+0x40/0x60)
Exception stack(0xc09e7fb0 to 0xc09e7ff8)
7fa0:                                     00001431 00000d31 0271e2d0 0271cea0
7fc0: b6d3a4d8 00001430 00002161 00000160 0271cea0 00000fff fffff000 0271d000
7fe0: 00000003 b566e800 b6ca30e4 b6ce008c 20000010 ffffffff
 r8:0271cea0 r7:00000160 r6:ffffffff r5:20000010 r4:b6ce008c
Mem-info:
Normal per-cpu:
CPU    0: hi:    0, btch:   1 usd:   0
active_anon:3734 inactive_anon:0 isolated_anon:0
 active_file:159 inactive_file:376 isolated_file:0
 unevictable:0 dirty:0 writeback:68 unstable:0
 free:180 slab_reclaimable:175 slab_unreclaimable:1112
 mapped:129 shmem:1 pagetables:39 bounce:0
Normal free:720kB min:720kB low:900kB high:1080kB active_anon:14936kB inactive_anon:0kB active_file:636kB inactive_file:1504kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:32512kB mlocked:0kB dirty:0kB writeback:272kB mapped:516kB shmem:4kB slab_reclaimable:700kB slab_unreclaimable:4448kB kernel_stack:344kB pagetables:156kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:7062 all_unreclaimable? yes
lowmem_reserve[]: 0 0
Normal: 0*4kB 0*8kB 1*16kB 0*32kB 1*64kB 1*128kB 0*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 720kB
536 total pagecache pages
0 pages in swap cache
Swap cache stats: add 0, delete 0, find 0/0
Free swap  = 0kB
Total swap = 0kB
8192 pages of RAM
244 free pages
1394 reserved pages
788 slab pages
687 pages shared
0 pages swap cached
[ pid ]   uid  tgid total_vm      rss cpu oom_adj oom_score_adj name
[  507]     0   507      269       52   0     -17         -1000 udevd
[  556]     0   556      269       51   0     -17         -1000 udevd
[  558]     0   558      269       51   0     -17         -1000 udevd
[  733]     0   733      468       44   0       0             0 sh
[  957]     0   957    16868     3753   0       0             0 app.out
Out of memory: Kill process 957 (app.out) score 524 or sacrifice child
Killed process 957 (app.out) total-vm:67472kB, anon-rss:14496kB, file-rss:516kB
Killed

二:引起的原因:
操作系统构建在进程的基础上。
进程由内核进行调度和维护,其中有一个内核作业称为“Out of memory killer(OOM终结者)”;
Out of memory killer 在系统可用内存极低的情况下会杀死某些进程;

三:示例;
当链表在一端申请内存写入数据,而另一端在读取数据释放内存,
如果读取的速度小于申请的速度,那么系统内存迟早被该进程耗尽;

RTPbuf_s *p = (RTPbuf_s *)malloc(sizeof(RTPbuf_s));	//申请内存

free(p);	//释放内存

四:linux下查看某一进程所占内存的方法:
1.首先使用ps -ef指令找到该进程id,
如下
ps -ef | grep app.out

/mnt/test # ps -ef | grep app.out
  965 root       0:12 ./app.out
  976 root       0:00 grep app.out

2.杀死某一进程:
第一种:
killall 进程名

killall app.out

第二种:给进城发一个杀死进程的信号:
kill -9 进程id

kill -9 965

3.linux中的所有信号:
kill -l

aston@ubuntu:~$ kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
 6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
31) SIGSYS	34) SIGRTMIN	35) SIGRTMIN+1	36) SIGRTMIN+2	37) SIGRTMIN+3
38) SIGRTMIN+4	39) SIGRTMIN+5	40) SIGRTMIN+6	41) SIGRTMIN+7	42) SIGRTMIN+8
43) SIGRTMIN+9	44) SIGRTMIN+10	45) SIGRTMIN+11	46) SIGRTMIN+12	47) SIGRTMIN+13
48) SIGRTMIN+14	49) SIGRTMIN+15	50) SIGRTMAX-14	51) SIGRTMAX-13	52) SIGRTMAX-12
53) SIGRTMAX-11	54) SIGRTMAX-10	55) SIGRTMAX-9	56) SIGRTMAX-8	57) SIGRTMAX-7
58) SIGRTMAX-6	59) SIGRTMAX-5	60) SIGRTMAX-4	61) SIGRTMAX-3	62) SIGRTMAX-2
63) SIGRTMAX-1	64) SIGRTMAX	

4.最常见的杀戮信号是:

信号名称	单值	影响
SIGHUP	1	挂断
SIGINT	2	从键盘中断
SIGKILL	9	杀死信号
SIGTERM	15	终止信号
SIGSTOP	171923	停止进程

猜你喜欢

转载自blog.csdn.net/yanghangwww/article/details/111992079