我正在运行一个实验性 Java 应用程序,每次我终止或停止该应用程序时,都会创建僵尸进程。我知道僵尸并不是真正的问题,因为它们(据说)不会消耗资源。但是,我的 RAM 可用空间明显少于应有的空间。这是
的转储ps aux | grep java
3052 8.5 0.0 0 0 ? Zl Sep24 127:24 [java] <defunct>
6644 0.9 0.0 0 0 ? Zl Sep24 13:20 [java] <defunct>
8325 0.7 0.0 0 0 ? Zl Sep24 11:01 [java] <defunct>
8954 0.7 0.0 0 0 ? Zl Sep24 11:01 [java] <defunct>
16229 1.3 0.0 0 0 ? Zl Sep24 16:57 [java] <defunct>
19222 106 0.0 0 0 ? Zl Sep24 1346:37 [java] <defunct>
以下均无效:(
kill -9 PID , kill -1 PID, kill -KILL PID
我无法重启我的机器!所以我非常欢迎任何解决方案。
最佳答案
wait(2) 手册页告诉您:
A child that terminates, but has not been waited for becomes a "zombie". The kernel maintains a minimal set of information about the zombie process (PID, termination status, resource usage information) in order to allow the parent to later perform a wait to obtain information about the child. As long as a zombie is not removed from the system via a wait, it will consume a slot in the kernel process table, and if this table fills, it will not be possible to create further processes. If a parent process terminates, then its "zombie" children (if any) are adopted by init(8), which automatically performs a wait to remove the zombies.
所以你必须寻找你的僵尸的父进程ID并杀死它们。然后 init
将埋葬你的僵尸。为此,ps -f
或 pstree
将为您提供帮助。
关于linux - 杀死一个java僵尸进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12588061/