http://blog.csdn.net/taiyang1987912/article/details/41695895
一、问题
当安装虚拟机时系统时没有设置swap大小或设置内存太小,编译程序会出现virtual memory exhausted: Cannot allocate memory的问题,可以用swap扩展内存的方法。
二、解决方法
在执行free -m的是时候提示Cannot allocate memory:
(swap文件可以放在自己喜欢的位置如/var/swap)
- [root@Byrd byrd]# free -m
- total used free shared buffers cached
- Mem: 512 108 403 0 0 28
- -/+ buffers/cache: 79 432
- Swap: 0 0 0
- [root@Byrd ~]# mkdir /opt/images/
- [root@Byrd ~]# rm -rf /opt/images/swap
- [root@Byrd ~]# dd if=/dev/zero of=/opt/images/swap bs=1024 count=2048000
- 2048000+0 records in
- 2048000+0 records out
- 2097152000 bytes (2.1 GB) copied, 82.7509 s, 25.3 MB/s
- [root@Byrd ~]# mkswap /opt/images/swap
- mkswap: /opt/images/swap: warning: don't erase bootbits sectors
- on whole disk. Use -f to force.
- Setting up swapspace version 1, size = 2047996 KiB
- no label, UUID=59daeabb-d0c5-46b6-bf52-465e6b05eb0b
- [root@hz mnt]# swapon /opt/images/swap
- [root@hz mnt]# free -m
- total used free shared buffers cached
- Mem: 488 481 7 0 6 417
- -/+ buffers/cache: 57 431
- Swap: 999 0 999
内存太小,增加内存可以解决。
使用完毕后可以关掉swap:
- [root@hz mnt]# swapoff swap
- [root@hz mnt]# rm -f /opt/images/swap
swap文件也可以不删除,留着以后使用,关键是你的虚拟机硬盘够用。
相关推荐
编译时virtual memory exhausted Cannot allocate memory 内存增加.docx
云服务器编译安装PHP遇到virtual memory exhausted: Cannot allocate memory
mmap: Cannot allocate memory 但是,该系统似乎并没有像Java那样锁定。 同一用户可以运行另一个mmap测试: cwb@laptop$ (./a.out | tail -1) & (./a.out | tail -1) mmap: Cannot allocate memory mmap: Cannot ...
php Allowed memory size of 134217728 bytes exhausted
主要介绍了Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2611816 bytes)错误的解决方法,需要的朋友可以参考下
php解决Allowed memory size of bytes exhausted
说他在安装wordpress安装包时遇到这样一个问题:Fatal error:Allowed memory size of 67108864 bytes exhausted (tried to allocate 76 bytes) in…..这个问题小编以前没遇到过,根据提示肯定是内存溢出造成的。至于...
Websphere Application Server WAS 内存溢出分析,帮助分析内存问题
本文实例讲述了ThinkPHP提示错误Fatal error: Allowed memory size的解决方法。...错误提示:Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 523800 bytes) in /var/w
虚拟内存不足方案虚拟内存不足方案虚拟内存不足方案虚拟内存不足方案虚拟内存不足方案虚拟内存不足方案虚拟内存不足方案
有些朋友新配置的环境或自己新写的程序运行时会碰到fatal error: Allowed memory size of 134217728 bytes exhausted错误,这种问题一个是程序写得不好导致的,另一个是环境配置不好也会出现,像php5.1.27+apache2.2.3...
dbcp 连接池不合理的锁导致连接耗尽解决方案 ... nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted at org.springframework.jdbc.dataso
/* The memory we search for has to include the memory * control block, but the users of malloc don't need * to know this, so we'll just add it in for them. */ numbytes = numbytes + sizeof...
主要介绍了阿里dubbo出错提示Thread pool is EXHAUSTED的问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
PHP Fatal error: Allowed memory size of 134217728 bytesexhausted (tried toallocate 135168 bytes) 跟踪代码发现,是在插入时以下代码造成的: EduOCRTaskBackup::getDb()->createCommand()->batchInsert...
在运行PHP程序,通常会遇到“Fatal Error: Allowed memory size of xxxxxx bytes exhausted”的错误, 这个意味着PHP脚本使用了过多的内存,并超出了系统对其设置的允许最大内存
Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 103 bytes) 错误提示:php所分配到的100M内存被占用完毕。 二、解决方法: 最简单的解决办法是:在执行文件的头部增加: ini...
Allowed memory size of 8388608 bytes exhausted (tried to allocate 1298358 bytes) 出现该错误的原因:在确保不是程序产生的原因(例如死循环),是由于php页面消耗的最大内存默认是为 8M (在PHP的ini件里可以...