Today I got 10 emails from my web hosting, all about High Memory Usage Messages. My hosting is 2 cores, 4 GB memories, online on Magento 2.3,6 based glasses shop for https://www.optical4u.com. I am using Centos 7, Nginx.
I forgot the position of the swap memory location, we can use one of the following method to check the swap file location.
swapon -s
cat /proc/swaps
cat /etc/fstab
cat /etc/fstab | grep -i swap
I think I may set the swap memory too small. So I plan to delete the 2 GB swap memories:
[glasses@optical4u /]# cat /etc/fstab | grep -i swap
/var/swapfile swap swap defaults 0 0
Delete the swap memory by running:
swapoff /var/swapfile
rm -rf /var/swapfile
Now let’s check memory information:
free -m
Swap 0 0 0
Create a 6 GB swap memory:
dd if=/dev/zero of=/var/swapfile bs=1024 count=6144000
mkswap /var/swapfile
swapon /var/swapfile
Check swap memory again:
free
Swap: 6143996 0 6143996
In order to let the swap memory run automatically, edit vim /etc/fstab.
Delete:
/swap none swap sw 0 0
Add:
/usr/swap/swapfile swap swap defaults 0