运行中的程序突然出现"Killed"原因

最近在做性能测试,大量数据进行测试时进程突然中止,出现 "Killed" 提示。

[root@Thor msg]# ./Msg
Killed

查阅资料发现了原因:

原因:程序内存上限超出后被kill掉

 Linux 内核有个机制叫OOM killer(Out Of Memory killer),该机制会监控那些占用内存过大,尤其是瞬间占用内存很快的进程,然后防止内存耗尽而自动把该进程杀掉。

那如何查看被系统Kill掉的进程?

需要借助系统日志信息进行查看。

[root@Thor record]# grep "Out of memory" /var/log/messages										
Jan 17 15:03:08 localhost kernel: Out of memory: Kill process 7863 (Server) score 149 or sacrifice child						
Jan 17 17:04:55 localhost kernel: Out of memory: Kill process 11449 (Msg) score 334 or sacrifice child						
Jan 17 18:24:29 localhost kernel: Out of memory: Kill process 34225 (Msg) score 334 or sacrifice child						
Jan 19 11:05:09 Thor kernel: Out of memory: Kill process 32249 (Msg) score 325 or sacrifice child						
[root@Thor msg]# egrep -i -r 'killed process' /var/log					
/var/log/messages:Jan 17 15:03:08 localhost kernel: Killed process 7863 (Server), UID 0, total-vm:51731832kB, anon-rss:20205220kB, file-rss:170520kB, shmem-rss:12288kB			
/var/log/messages:Jan 17 17:04:55 localhost kernel: Killed process 11449 (Msg), UID 0, total-vm:70144784kB, anon-rss:48144592kB, file-rss:0kB, shmem-rss:0kB			
/var/log/messages:Jan 17 18:24:29 localhost kernel: Killed process 34225 (Msg), UID 0, total-vm:69800712kB, anon-rss:48174008kB, file-rss:0kB, shmem-rss:0kB			
/var/log/messages:Jan 19 11:05:09 Thor kernel: Killed process 32249 (Msg), UID 0, total-vm:68817672kB, anon-rss:46874480kB, file-rss:0kB, shmem-rss:0kB			

 

你可能感兴趣的:(Linux,linux,kill,进程中止)