Home » Php » laravel queue:work out of memory

laravel queue:work out of memory

Posted by: admin October 26, 2017 Leave a comment

Questions:

When I run command in terminal

php artisan queue:work

I got Error:

mmap() failed: [12] Cannot allocate memory PHP Fatal error: Out of
memory (allocated 10303311872) (tried to allocate 262144 bytes) in
/var/www/html/grubily/vendor/illuminate/container/Container.php on
line 575

mmap() failed: [12] Cannot allocate memory PHP Fatal error: Out of
memory (allocated 10303311872) (tried to allocate 262144 bytes) in
/var/www/html/grubily/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php
on line 65

My Droplet Configuration is:

8 GB Memory / 40 GB Disk / NYC3 – Ubuntu WordPress 4.7 on 16.04

Also I created swap file

Answers:

Your script runs out of memory.
I suggest you optimize your code by loading in memory smaller amount of information by, for example, processing the data you load in smaller chunks.(262144 bytes is around 2.1 Mb)

If you still prefer to go on and load it all at a time, you still can increase the memory available for php:

$memory_limit = ini_get('memory_limit');
ini_set('memory_limit','4M');
// process your data

// reset previous limit
ini_set('memory_limit',$meḿory_limit);