zoukankan      html  css  js  c++  java
  • linux编译时报错:virtual memory exhausted: Cannot allocate memory,向磁盘借用swap空间

    编译时,报错:virtual memory exhausted: Cannot allocate memory

    1G内存不够用,增加swap空间解决

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

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

    free -m 查看内存状态
    [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或删除swap:

    [root@hz mnt]# swapoff swap  
    [root@hz mnt]# rm -f /opt/images/swap

    硬盘空间够的话,swap文件也可以不删除,留着以后使用。

  • 相关阅读:
    tableView的高度问题
    信任机型
    cell 内部 设置width 总不对
    图文混排
    UICollectionview实现自定义cell的移动删除
    ios 各种技术
    打包ane之后在FB上生成ipa的阶段错误
    自动布局出代码植入 的图像化实例
    MapReduce编程实例
    二叉树的遍历(递归遍历、非递归遍历、层序遍历)
  • 原文地址:https://www.cnblogs.com/jackron/p/14071613.html
Copyright © 2011-2022 走看看