1. Question
When installing the virtual machine, the system does not set the swap size or the memory is too small. The compiler will have the problem of virtual memory exhausted: cannot allocate memory. You can use swap to expand memory.
2. Solution
When free – M is executed, the prompt cannot allocate memory:
(swap files can be placed in their favorite location, such as/var/swap)
[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
Memory is too small. Increasing memory can solve this problem
You can turn off swap after use:
[root@hz mnt]# swapoff swap
[root@hz mnt]# rm -f /opt/images/swap
Swap files can also not be deleted and kept for future use. The key is that your virtual machine hard disk is enough.
Similar Posts:
- How to Solve ORACLE Error: ORA-27102: out of memory
- Mysql Auto Downtime ERROR: InnoDB: Cannot allocate memory for the buffer pool [Solved]
- C++: internal compiler error: Killed (program cc1plus) [How to Solve]
- Nginx an upstream response is buffered to a temporary file,nginx502 Error
- Execute composer and throw killed
- [Solved] WordPress Error: Allowed memory size of 134217728 bytes exhausted
- Eclipse failed to create the java virtual machine [How to Solve]
- mysqlmmap(137428992 bytes) failed; errno 12,Cannot allocate memory for the buffer pool
- eclipse.ini/myeclipse.ini -Xms,-Xmx,-PerSize
- [Solved] Insufficient Oracle table space: ora-01653: unable to extend table