Reputation: 87
I am encoutering the following error with Symfony 5 when trying to
bin/console cache:clear
I know how I could patch that (memory_limit=-1) but I want know why I have this error.
Error :
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32230840 bytes) in /Applications/MAMP/htdocs/Toile./vendor/twig/twig/src/Lexer.php on line 157
15:50:13 CRITICAL [php] Fatal Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32230840 bytes)
[ "exception" => Symfony\Component\ErrorHandler\Error\OutOfMemoryError { -error: [ "type" => 1, "message" => "Allowed memory size of 134217728 bytes exhausted (tried to allocate 32230840 bytes)", "file" => "/Applications/MAMP/htdocs/Toile./vendor/twig/twig/src/Lexer.php", "line" => 157 ] #message: "Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32230840 bytes)" #code: 0 #file: "./vendor/twig/twig/src/Lexer.php" #line: 157 } ]
In Lexer.php line 157: Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32230840 bytes)
I am unable to track from where this error comes from.
I removed all twig templates from my project, I clearing the cache manually but nothing .. Any idea?
Thanks
Upvotes: 6
Views: 13099
Reputation: 649
Check all your Project Directory if some of code doesn't contain any lines like this: ini_set('memory_limit'
— Symfony parses all classes and takes into account it.
For example, in my case there was: ini_set('memory_limit', '42M');
and 42MB was not enough to run console task.
Upvotes: 0
Reputation: 574
It looks like the bin/console cache:clear
command takes up a lot of memory. I don't think it's because of the twig files.
setting up memory_limit=-1
is sort of you are disabling the memory limit, means giving unlimited of memory to run PHP. Please check your php.ini file and adjust the memory_limit.
Note that you might have 2 php.ini files for PHP, one for web and one for command-line use. Use php -i
to see the loaded ini file.
Use this command php -i | grep 'Configuration'
to grep the output from command line.
Upvotes: 3