【进程&线程】关于bash: fork: Cannot allocate memory 问题的处理

bash:fork:Cannot allocate memory 问题的处理

https://zhanglianghhh.github.io/2019/08/30/linux-thread


fork Cannot allocate memory

https://developer.aliyun.com/article/762291

https://stackoverflow.com/questions/43652021/bash-fork-cannot-allocate-memory


基本命令都显示无法分配内存错误。 

经排查,发现系统正在使用所有内存进行缓存,并且没有释放内存。

 这称为“缓存膨胀”,通过清除缓存来解决。



就我的案例而言,操作系统是用尽了PID而不是内存。

在我的场景中,根本原因是一个Java进程产生了18k +个线程(在Linux内核中,线程本质上是一个进程)。


LWP -- 轻量级进程,即线程

NLWP -- 线程数,即 number of threads in process


#  ps -eo nlwp,pcpu,user,pid,ppid,args  --sort nlwp  

注:以 nlwp排序,默认正序

# man ps 


Running any command returns “Cannot allocate memory” on Ubuntu Server

https://askubuntu.com/questions/845233/running-any-command-returns-cannot-allocate-memory-on-ubuntu-server


How does the OOM killer decide which process to kill first?

https://unix.stackexchange.com/questions/153585/how-does-the-oom-killer-decide-which-process-to-kill-first/153586#153586


最全Linux ps命令详解

https://www.sohu.com/a/306726762_262549




如何查看某进程下运行的线程

https://my.oschina.net/moooofly/blog/160160


一个类似top查看每个人使用进程数的命令

https://www.yuque.com/leoatchina/blog/iw0sc4


Linux中查看进程的多线程

http://smilejay.com/2012/06/linux_view_threads

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容