zoukankan      html  css  js  c++  java
  • (转)linux centos 编译luabind-0.9.1 动态库 静态库

    编译时:virtual memory exhausted: Cannot allocate memory

    一、问题

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

    二、解决方法

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

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

    [html] view plain copy
     
    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 plain copy
     
    1. [root@hz mnt]# swapoff swap  
    2. [root@hz mnt]# rm -f /opt/images/swap  
    swap文件也可以不删除,留着以后使用,关键是你的虚拟机硬盘够用。
  • 相关阅读:
    求转置矩阵问题
    喷水装置
    面试之谈
    迭代任意8种数据类型数组
    Session那点事
    随机验证码
    正则表达式:网页爬虫
    模拟上传服务端
    Properties集合的练习
    用递归算法对指定目录的深度遍历
  • 原文地址:https://www.cnblogs.com/xingchong/p/9082242.html
Copyright © 2011-2022 走看看