Sarbjeet Singh
Sarbjeet Singh

Reputation: 85

laravel queue:work out of memory

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

Upvotes: 0

Views: 1504

Answers (1)

Evhz
Evhz

Reputation: 9275

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);

Upvotes: 1

Related Questions