黑猫

virtual memory exhausted: Cannot allocate memory 解决方法
阿里云服务器在安装PHP拓展时报错:virtual memory exhausted: Cannot alloca...
扫描右侧二维码阅读全文
12
2018/09

virtual memory exhausted: Cannot allocate memory 解决方法

阿里云服务器在安装PHP拓展时报错:

virtual memory exhausted: Cannot allocate memory

原因是由于物理内存本身很小,且阿里云服务器并没有分配swap空间,当物理内存不够用时, 物理内存中暂时不用的内容没地方转存。

解决方法

手动分配一个swap空间
dd if=/dev/zero of=/swap bs=1024 count=1M
#创建一个大小为1G的文件/swap
mkswap /swap
#将/swap作为swap空间
swapon /swap
#enable /swap file for paging and swapping
echo "/swap swap swap sw 0 0" >> /etc/fstab
#Enable swap on boot, 开机后自动生效

Last modification:September 12th, 2018 at 03:13 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment