Today, when I compiled a large C project on the Raspberry Pi, I found that the speed would be very slow and crashed after each compilation to 43. Baidu later found that the swap space might be insufficient, and the crash problem was solved only after adding 1G of swap space.
The default swap space of Raspberry Pi 3B is 99m, which is obviously not enough for compiling some larger projects, and it is easy to crash. The solution for increasing swap is given below.
Add a swap space to /opt/image
cd / opt sudo mkdir image cd image sudo touch swap #create file sudo dd if=/dev/zero of=/opt/image/swap bs=1024 count=1024000 #Add a swap file and set it to 1G # will return after a while (this is slightly slower) #1024000+0 records in #1024000+0 records out #size copied, time used s, speed MB/s sudo mkswap /opt/image/swap #Set up swap space sudo swapon /opt/image/swap #Enable the new swap space free -m #Confirm whether it has taken effect
#Afterwards, modify the /etc/fstab file so that this swap can take effect after restarting, and add it at the end of the file
/opt/image/swap /swap swap defaults 0 0Reference link: https://blog.csdn.net/wxz3wxz/article/details/70237302