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:  Cannot allocate memory
mmap() failed:  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.
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.