0

Laravel job listener is running over 10s of thousands of records, and giving the error

PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 1179648 bytes) in .../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php on line 184


[Symfony\Component\Debug\Exception\FatalErrorException]                             
 Allowed memory size of 268435456 bytes exhausted (tried to allocate 1179648 bytes)  

I have proven using phpinfo() that the memory_limit = 512M, so I'm at a loss as to what is happening when 512 > 268 :) - also what has belongsTo relationship got to do with it ?

Zamrony P. Juhara
  • 5,222
  • 2
  • 24
  • 40
yoyoma
  • 3,336
  • 6
  • 27
  • 42
  • Possible duplicate of [Allowed memory size of 536870912 bytes exhausted in Laravel](https://stackoverflow.com/questions/34864524/allowed-memory-size-of-536870912-bytes-exhausted-in-laravel) – bharat Feb 01 '18 at 05:04

1 Answers1

2

You mention Laravel job listener which make me assume that you run it through command line. php.ini for command line execution may be different than what web server load. Please make sure the memory_limit value are same for both php.ini. To find where php.ini for command line, from shell (assuming Linux), run

$ php -i | grep php\.ini
Zamrony P. Juhara
  • 5,222
  • 2
  • 24
  • 40
  • it seems this might be the answer that tricked me - i found command line php.ini at /etc/ , so if I change this I need to just reload php ? Or whole server ? – yoyoma Feb 01 '18 at 04:53
  • oh since its the job listener - i just need to restart the listener for php.ini to take effect? – yoyoma Feb 01 '18 at 04:57
  • 1
    AFAIK, `php.ini` will be read everytime you run php through command line. Yes. You need to restart job listener. – Zamrony P. Juhara Feb 01 '18 at 04:57