Debian 9 (1 GB RAM, 25 GB storage) Apache MariaDB PHP 7.2
Composer and Laravel installed successfully
Then, attempted to add a package with composer … ran following line in Putty composer require mobiledetect/mobiledetectlib
returned the following…
Using version ^2.8 for mobiledetect/mobiledetectlib ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev)
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory PHP Fatal error: Out of memory (allocated 878714880) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223
Fatal error: Out of memory (allocated 878714880) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223
Checked for the mobiledetect folder in /var/www/domainname/html/projectname/vendor but no folder there
Currently have 1 GB RAM in DigitalOcean, do I need to up it to 2 GB RAM for composer to run updates properly?
I ran the command … php -r “echo ini_get(‘memory_limit’).PHP_EOL;” and -1 was returned which means unlimited
I checked the php.ini file and found… ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit memory_limit = -1
I used the ‘top’ command to view that only 1 % of CPU is in use
and free -m returns total used free shared buff/cache available Mem: 996 134 800 21 60 750
I read that composer increases internal memory to 1.5 GB here https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
Any suggestions would be appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
The OS you’re using plays an integral role in memory management, one of the easy hacks to eliminate these memory errors is to add Swap memory file and SSD storage also helps in faster swaps. Refer to the tutorial below: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7
Hello @anjanesh
If you’re expecting moderate to high traffic for the site, then I’m afraid 512MB RAM will not be enough the handle the requests. However, if this is a side project then it does not require a lot of resources for now it’s a good starting point.
I’ll also recommend adding SWAP space on your droplet, which will significantly improve its performance.
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-22-04
Laravel is also available as a one-click installation app through our marketplace portal. You can find the application here:
https://marketplace.digitalocean.com/apps/laravel
We also have a pretty neat tutorial on How To Install and Configure Laravel with Nginx find the link for the article below:
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-laravel-with-nginx-on-ubuntu-22-04
Regards