Composer update – Cannot allocate memory [issue] [fixed]

Are you tying to run composer update but not able to complete the operation? Well, let me give you a simple solution for this. But before that let me tell you how to see detail information while updating composer. Type composer update -vvv and you can see detail list of what update operation is actually doing. Ok, now let’s move to the solution for this.

The issue lies with swap memory. If you are out of swap memory, you won’t be able to run composer update command. Here is the command to check your swap memory.

free -h

I have made swap memory 5GB in total. While updating composer, you will require huge space. You might have 1 GB space initially or may be around it. So, to make sure the update works properly without space issue, please follow following commands and you are good to go.

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=2M count=2048
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

You will require to provide admin password while executing first command. Now, try again with the command composer update. Boom?. Done ✅.

That is all guys. Hope this will help you. If so you know what to do ?.

Thank you.

Tags :

Leave a Reply