一、问题 : 虚拟内存耗尽,无法分配内存PHP

当安装虚拟机时系统时没有设置swap大小或设置内存太小,编译程序会出现virtual memory exhausted: Cannot allocate memory的问题,可以用swap扩展内存的方法。

二、解决方法

在执行free -m的是时候提示Cannot allocate memory:

(swap文件可以放在自己喜欢的位置如/var/swap)

[html] view plaincopy
  1. [root@Byrd byrd]# free -m
  2. total       used       free     shared    buffers     cached
  3. Mem:           512        108        403          0          0         28
  4. -/+ buffers/cache:         79        432
  5. Swap:            0          0          0
  6. [root@Byrd ~]# mkdir /opt/images/
  7. [root@Byrd ~]# rm -rf /opt/images/swap
  8. [root@Byrd ~]# dd if=/dev/zero of=/opt/images/swap bs=1024 count=2048000
  9. 2048000+0 records in
  10. 2048000+0 records out
  11. 2097152000 bytes (2.1 GB) copied, 82.7509 s, 25.3 MB/s
  12. [root@Byrd ~]# mkswap /opt/images/swap
  13. mkswap: /opt/images/swap: warning: don't erase bootbits sectors
  14. on whole disk. Use -f to force.
  15. Setting up swapspace version 1, size = 2047996 KiB
  16. no label, UUID=59daeabb-d0c5-46b6-bf52-465e6b05eb0b
  17. [root@hz mnt]# swapon /opt/images/swap
  18. [root@hz mnt]# free -m
  19. total       used       free     shared    buffers     cached
  20. Mem:           488        481          7          0          6        417
  21. -/+ buffers/cache:         57        431
  22. Swap:          999          0        999

内存太小,增加内存可以解决。

使用完毕后可以关掉swap:

[html] view plaincopy
  1. [root@hz mnt]# swapoff swap
  2. [root@hz mnt]# rm -f /opt/images/swap

swap文件也可以不删除,留着以后使用,关键是你的虚拟机硬盘够用。

编译时:virtual memory exhausted: Cannot allocate memory相关推荐

  1. virtual memory exhausted: Cannot allocate memory Linux虚拟内存不足,扩展虚拟内存的解决办法

    Linux虚拟内存不足,扩展虚拟内存的解决办法 virtual memory exhausted: Cannot allocate memory 在编译软件的时候,出现了这个错误: virtual m ...

  2. 阿里云上遇到: virtual memory exhausted: Cannot allocate memory

    # dd if=/dev/zero of=/swap bs=1024 count=1M  Format the swap file:  # mkswap /swap  Enable the swap ...

  3. Centos安装php提示virtual memory exhausted: Cannot allocate memory

    由于内存不够,需要在php配置的时候./configure最后添加上 --disable-fileinfo >>./configure --prefix= ...........   -- ...

  4. 微信小程序 RangeError: WebAssembly.Memory(): could not allocate memory

    问题描述: 最近在使用微信小程序的开发工具时,不管是新项目还是老项目,只要一编译保存就是报错,具体报错内容:RangeError: WebAssembly.Memory(): could not al ...

  5. 编译安装php时遇到virtual memory exhausted: Cannot allocat

    编译安装php时遇到virtual memory exhausted: Cannot allocate memory 本人近期就遇到一个这样的问题:在512MB内存centos操作系统的VPS上编译安 ...

  6. mount cifs出现cannot allocate memory解决方法

    今天囧了啊,在ubuntu挂载的文件夹里面解压数据库,结果linux嫌太大挂掉了直接mount error(12): Cannot allocate memory折腾了好久,终于发现解决办法: 方法一 ...

  7. 【Linux】 -bash-4.2#问题和Cannot allocate memory

    1,最近在实际使用linux的过程中中,遇到了一个小问题 在之前,看到根目录"/"下多了一个"~"目录,看到别的服务器都没有,于是忍不住rm -rf ~了.运行 ...

  8. 解决Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示

    Android 启动模拟器是出现" Failed to allocate memory: 8"错误,模拟器无法启动,如下: [2012-11-26 13:40:12 - TestS ...

  9. CUDA out of memory. Tried to allocate 14763.13 GiB (GPU 3; 10.73 GiB total capacity; 165.28 MiB alre

    RuntimeError: CUDA out of memory. Tried to allocate 14763.13 GiB (GPU 3; 10.73 GiB total capacity; 1 ...

  10. RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capacity; 3.41

    pytorch报错:RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capa ...

最新文章

  1. 自动驾驶资料合集:视频、书籍与开源项目
  2. 第四范式陈雨强:万字深析工业界机器学习最新黑科技
  3. postfix+mysql+dovecot
  4. 【FFMPEG】关于硬解码和软解码
  5. 用数字告诉你2014年Google的野心在哪里
  6. TOJ 4393 Game
  7. Marketing Cloud的语音输入功能
  8. 三个不等_2道真题,讲透「基本不等式」的使用原则 | 真题精讲-11
  9. 冲刺阶段站立会议每天任务1
  10. 《Splunk智能运维实战》——第1章 游戏时间——导入数据 1.1 简介
  11. 转摘:工厂方法模式(Factory Method Pattern)
  12. 使用R语言的BNLearn包实现贝叶斯网络
  13. 【Caffe代码解析】convert_imageset
  14. android获取Mac地址和IP地址
  15. 车载双目相机,老兵的二次出征
  16. C++SLT入门简介
  17. 打印小册子中断了怎么办
  18. Java Geometry空间几何数据的处理应用
  19. 网页引入谷歌字体_在网页中使用Google字体
  20. 虚拟机如何进入PE系统

热门文章

  1. HUSTOJ(2019)在线判题系统的从零开始搭建过程
  2. cefsharp 网页打印不好用_WinFrom 的 WebBrowser 替换为 CefSharp
  3. python课程典范选优_python 实现选课系统
  4. free mybatis 不生效_Mybatis非空判断没有生效
  5. android局域网调试无法安装,真机调试出现:INSTALL_FAILED_USER_RESTRICTED 安装错误解决方案...
  6. c语言串口接收的字符转int,从串口发送和接收int值
  7. Pyspark:随机森林
  8. 翻译: 3.7. Softmax 回归的简明实现 pytorch
  9. 算法:Design Circular Deque(设计一个双端队列)
  10. java 如何将word 转换为ftl_3种方法轻松将PDF转换为Word文档,办公必备