Reputation: 141
In my laravel 5.4 project, I can not run php artisan
command. An Allowed memory size of 2097152 bytes exhausted
error occured. The website can be view properly in the browser, and laravel.log is also empty, but artisan
command in the terminal failed,like this:
➜ laravel git:(dev) ✗ php artisan
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 4096 bytes) in /var/www/laravel/vendor/symfony/finder/Finder.php on line 120
It seems like the memory is not enough, I set bigger value for memory_limit
,like this:
➜ laravel git:(dev) ✗ php -i |grep memory_limit
memory_limit => 2048MB => 2048MB
But it did not work,could anyone help me, please?
Upvotes: 1
Views: 7168
Reputation: 220
Locate your php.ini file by writing php --ini
in the console (in my case it is located in /etc/php/7.2/cli/
). Open php.ini, locate the line that sets memory_limit
, and set it equal to -1
(memory_limit=-1)
.
Upvotes: 1
Reputation: 733
I got this type of error as laravel could not connect to Database. In Laravel 5.4, if database is not connected, it take lot of memory. I think, this is the bug in 5.4.
In general, to increase the memory limit, goto terminal and type "php --ini". This will show as $ php --ini
Configuration File (php.ini) Path: /Applications/XAMPP/xamppfiles/etc Loaded Configuration File: /Applications/XAMPP/xamppfiles/etc/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none)
This will show the location of php.ini file in your system.
2) Then open php.ini file in vi search for memory_limit using '/' in command mode. Then edit the line by pressing 'i' and memory_limit=2000:M.
3) press esc and type ":wq" (To save and quit)
Upvotes: 1