what caused this error? When did it happen (what where you executing)? Do you have a stacktrace in your error log? (storage/logs/laravel.log)
Do you have an infinite loop that never ends and eats up memory?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, On my remote server(ubuntu 16, PHP 7.2.7-1+ubuntu16.04.1+deb.sury.org+1 ) in laravel 5.5 project I got error:
# composer require doctrine/dbal
Using version ^2.8 for doctrine/dbal
./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 596647936) (tried to allocate 20480 bytes) in /usr/share/php/Composer/DependencyResolver/Rule.php on line 66
Fatal error: Out of memory (allocated 596647936) (tried to allocate 20480 bytes) in /usr/share/php/Composer/DependencyResolver/Rule.php on line 66
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 0 487M 0% /dev
tmpfs 100M 11M 89M 11% /run
/dev/vda1 25G 2.3G 22G 10% /
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 497M 0 497M 0% /sys/fs/cgroup
/dev/vda15 105M 3.4M 101M 4% /boot/efi
tmpfs 100M 0 100M 0% /run/user/0
In my /etc/php/7.2/cli/php.ini:
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 3300
; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = 240
; Maximum input variable nesting level
; http://php.net/max-input-nesting-level
;max_input_nesting_level = 64
; How many GET/POST/COOKIE input variables may be accepted
; max_input_vars = 1000
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 1024M
upload_max_filesize = 400M
post_max_size = 400M
I restarted apache server times.
What is wrong and how to fix the error?
Thanks!
As you can see:
total used free shared buff/cache available
Mem: 992 325 562 35 104 518
Swap: 0 0 0
You have to little RAM in this server (only 1 GB total), but composer usually needs around 1GB to be able to resolve all dependencies. You only have around 560MB free.
There are 3 things you can do:
"composer update" locally, and "composer install" on the server, this way the server doesnt have to do the resolving, it just installs what your dev environment concluded to be the needed packages.For #3 you can follow this tutorial to setup a 1GB swap space on your server:
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04
Please or to participate in this conversation.