Linux VPS 临时添加 Swap¶
1. "Killed" error during make¶
When I tried to compile and install libtorrent on CentOS 7 server, I got a "Killed" error like this
2. Memory exhausted during compiling process¶
Thanks Jon Combe from Stack Overflow. It occurred me that perhaps the memory isn't sufficient. Due to the VPS environment, there is only 500 Mb of RAM and 256Mb of swap in total.
Of course, the most easiest way to solve this problem, is to pay more money to the VPS provider. But there's another way.
3. Detect if the memory is insufficient¶
After the make process exited with "Killed" error, run dmesg immediately to show kernel message. And if you found something like Out of memory: Kill process 23747 (cc1plus), that means the problem is just what we are talking about.
You can also run make in the background, run df -lh repeatedly.
4. Spare some space in your storage to swap¶
First, make a disk image using dd
Change count=16 to a larger number if more swap space is required.
Then, run
Run df -lh to show the new RAM and swap status.
5. Clean after use¶
After compiling, remember to delete the swap image to free your disk space.