Compile time: Virtual memory Exhausted:cannot Allocate memory

Source: Internet
Author: User

First, the question

When the virtual machine is installed when the system does not set the swap size or set the memory is too small, the compiler will appear the virtual memory Exhausted:cannot allocate memory problem, you can use swap to expand the Ram method.

Second, the solution

In the execution of Free-m is the time to prompt cannot allocate memory:

(Swap files can be placed in their preferred location such as/var/swap)

[HTML]View PlainCopy
  1. [Email protected] 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. [Email protected] ~]# mkdir/opt/images/
  7. [Email protected] ~]# Rm-rf/opt/images/swap
  8. [email protected] ~]# dd if=/dev/zero of=/opt/images/swap bs=1024x768 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. [Email protected] ~]# 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. [Email protected] mnt]# Swapon/opt/images/swap
  18. [Email protected] 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

Memory is too small to add memory to resolve.

After use, you can turn off swap:

[HTML]View PlainCopy 
    1. [[email protected] mnt]# Swapoff swap
    2. [Email protected] mnt]# rm-f/opt/images/swap

Swap files can also not be deleted, reserved for later use, the key is that your virtual machine hard disk enough.

Compile time: Virtual memory Exhausted:cannot Allocate memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.