4
votes

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

1
If it takes too much memory that's, because it takes too much memory so nothing you can do beside increasing the limit in the php.ini or via the command line, eg. php -dmemory_limit=1G bin/console ca:clemix
Thanks, I increasing the limit in the php.ini to 256MOtonyRICHER

1 Answers

1
votes

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.