zoukankan      html  css  js  c++  java
  • virtual memory exhausted: Cannot allocate memory

    问题描述:

    购买的Linux服务器,Linux服务器的内存为512MB。

    在编译PHP的时候会提示:virtual memory exhausted: Cannot allocate memory,编译失败。

     

    解决方法:

    发生该问题的原因是服务器的内存不够,从而导致编译失败。

    而购买的Linux服务器,未给你分配虚拟内存,所以可以通过自行增加虚拟内存的方法予以解决

    [root@iZ25p0h5gthZ ~]#  free -m  
                 total       used       free     shared    buffers     cached
    Mem:           994        707        287          0         11         57
    -/+ buffers/cache:        638        356 
    Swap:            0          0          0 
    

     第二步

    [root@iZ25p0h5gthZ ~]#  mkdir /usr/img/             
    [root@iZ25p0h5gthZ ~]# rm -rf /usr/img/swap
    [root@iZ25p0h5gthZ ~]#  dd if=/dev/zero of=/usr/img/swap bs=1024 count=2048000           
    
    
    2048000+0 records in
    2048000+0 records out
    2097152000 bytes (2.1 GB) copied, 48.7514 s, 43.0 MB/s
    

     第三步

    [root@iZ25p0h5gthZ ~]#  mkswap /usr/img/swap            
    mkswap: /usr/img/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=9982f566-9e44-4495-be0b-51d309873112
    [root@iZ25p0h5gthZ ~]# swapon /usr/img/swap 
    [root@iZ25p0h5gthZ ~]# free -m
                 total       used       free     shared    buffers     cached
    Mem:           994        924         70          0          1        269
    -/+ buffers/cache:        653        340 
    Swap:         1999          0       1999
    

     使用完毕后可以关掉swap

    [root@iZ25p0h5gthZ img]# swapoff swap  
    [root@iZ25p0h5gthZ img]# rm -f /usr/img/swap 
    
  • 相关阅读:
    uva 1511 最小生成树
    百度之星2017初赛A-1006-度度熊的01世界
    工作5年总结-总结这两年在阳光的日子
    在visual studio中查看源代码
    根据C#编程经验思考编程核心
    项目的可维护可持续性思考
    java学习
    What is ASP.NET SignalR
    WCF 和 ASP.NET Web API
    wcf服务
  • 原文地址:https://www.cnblogs.com/chenpingzhao/p/4820814.html
Copyright © 2011-2022 走看看