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
- [Email protected] byrd]# free-m
- Total used free shared buffers Cached
- MEM:512 108 403 0 0 28
- -/+ buffers/cache:79 432
- swap:0 0 0
- [Email protected] ~]# mkdir/opt/images/
- [Email protected] ~]# Rm-rf/opt/images/swap
- [email protected] ~]# dd if=/dev/zero of=/opt/images/swap bs=1024x768 count=2048000
- 2048000+0 Records in
- 2048000+0 Records out
- 2097152000 bytes (2.1 GB) copied, 82.7509 s, 25.3 MB/s
- [Email protected] ~]# 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
- [Email protected] mnt]# Swapon/opt/images/swap
- [Email protected] mnt]# free-m
- Total used free shared buffers Cached
- mem:488 481 7 0 6 417
- -/+ buffers/cache:57 431
- swap:999 0 999
Memory is too small to add memory to resolve.
After use, you can turn off swap:
[HTML]View PlainCopy
- [[email protected] mnt]# Swapoff swap
- [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