Compile: virtual memory exhausted: Cannot allocate memory, exhaustedallocate

Source: Internet
Author: User

Compile: virtual memory exhausted: Cannot allocate memory, exhaustedallocate
I. Problems

When the system does not set the swap size or the memory size is too small when installing the virtual machine, the Compilation Program will encounter the virtual memory exhausted: Cannot allocate memory problem. You can use swap to expand the memory.

Ii. Solution

The prompt "Cannot allocate memory" is displayed when free-m is executed:

(Swap files can be stored in your favorite location, such as/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-108e6b05eb0b
  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

The memory size is too small. Increasing the memory size can solve this problem.

 

After use, you can turn off the swap:

 

[Html]View plain copy
  1. [Root @ hz mnt] # swapoff swap
  2. [Root @ hz mnt] # rm-f/opt/images/swap

Swap files can also be deleted without being deleted and used later. The key is that your VM hard disk is sufficient.

Related Article

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.