Problem with Artisan: Allowed memory size of 134217728 bytes exhausted
Hi all,
I am using Laravel 8 for my project and everything worked perfectly. I updated my php via Brew from 8.0 to 8.1.3 and now all the sudden I get the following error when running any Artisan or Composer command:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 118784 bytes)
Has anybody seen this before? How can I solve this?
@tykus thanks but how do i find what is using this memory? Is there a way? This is on my local machine
Also, I downloaded php from brew on Monterey iOS, how do I increase the memory limit here.
I tried to find the php.ini and I am not sure I am doing it right
@tykus sorry for the late reply, I was away. Here is the output:
memory_limit => 128M => 128M
Collecting memory statistics => Yes
opcache.memory_consumption => 128 => 128
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => Off => Off
@eskiesirius okay - I don't know why that should be having a problem unless there is something in a ServiceProvider that is working with a lot of data? In most cases, finding the memory issue using profiling tools as described here is better (IMHO) than blindly increasing the memory limit.
Anyway, if you do decide to increase the memory_limit, on the terminal execute:
php --ini
Here, you will see where the loaded INI files are - you may have a specific memory-limits configuration file (e.g. /usr/local/etc/php/8.1/conf.d/php-memory-limits.ini), or you may need to go for the main config file (e.g. /usr/local/etc/php/8.1/php.ini) where you can bump up the memory_limit setting to, say, 512M.
@tykus I increased the limit and it worked. Thanks a lot. However, the important thing you brought my attention to is the App Service Provider, it has some data to load... I think I need to run some testing on that and see.
Many thanks for usual helps. I REALLY appreciate it. :)
I would try to increase you allowed memory. The limit is now 128M. So if you change this in your PHP.INI and restart the webserver, you should be good to go.
To find the php.ini you can run php -i in the terminal (this will output the entire php config)
or use php --ini in the terminal to see the loaded php.ini's. In this file you can change the memory.