Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cshelswell's avatar

Out of memory when deploying.

Hi I've come across a problem I'm trying to get round. I'd got some zip files in my public directory which are largish (100+ megabytes). I hadn't added the folder to gitignore and i think that's what's causing me to get the error below:

Warning: Permanently added the RSA host key for IP address '111.123.111.0' to the list of known hosts.
fatal: Out of memory, malloc failed (tried to allocate 181923709 bytes)
fatal: index-pack failed

I've since sorted the problem and removed the download packs but can't deploy through forge. Just wondering what the best way to get round this is?

Thanks

0 likes
2 replies
fideloper's avatar
Level 11

Howdy!

I'd recommend a server with at least 1gb of ram (which you might still have, but I'm guessing you may have a 512mb ram server as this issue is fairly common on servers with only 512mb of ram).

In any case, you can add "swap", which is a partition of the disk drive that the operating system can use when RAM is fully used. When swap is used, the server WILL slow down, but it can also prevent quick tasks like a deployment to work successfully without failing.

Some people would rather let the server fail and be alerted, but for this use case, I'd recommend enabling some swap.

Here's how: Log into your server and run the following:

# Create the Swap file, 1GB in size
sudo fallocate -l 1G /swapfile

# Set the correct Swap permissions
sudo chmod 600 /swapfile

# Setup Swap space
sudo mkswap /swapfile

# Enable Swap space
sudo swapon /swapfile

# Make the Swap file permanent
echo "/swapfile   none    swap    sw    0   0" | sudo tee -a /etc/fstab

# Add some swap settings:
# vm.swappiness=10: Means that there wont be a Swap file until memory hits 90% useage
# vm.vfs_cache_pressure=50: read http://rudd-o.com/linux-and-free-software/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that
printf "vm.swappiness=10\nvm.vfs_cache_pressure=50" | sudo tee -a /etc/sysctl.conf && sysctl -p
1 like
cshelswell's avatar

@fideloper Amazing thank you! That worked perfectly. The server is 1gb and the site isn't overly complicated. As I say I assume it was the large zip files causing the issue but i'll just upload those manually in future.

Thanks again - it was getting really annoying having to ftp everything now I'm used to forge :)

1 like

Please or to participate in this conversation.