I solved a long-running problem in my Matomo On Premises. I'm so excited. For a year I have had daily Matomo errors because I starved it for resources.
Matomo needs 2G of RAM. I run it on a $5 host plan so there is only 1G of RAM.
I got these errors frequently:
- mmap() failed: [12] Cannot allocate memory
- Error unserializing the following response from...
Solution:
Create SWAP space, in the memory!
1. free -h
2. sudo fallocate -l 2G /swapfile # Create a 2GB swap file
3. sudo chmod 600 /swapfile # Set the correct permissions
4. sudo mkswap /swapfile # Set up the swap space
5. sudo swapon /swapfile # Enable swap
6. Make it permanent, such as after a restart:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab