我在尝试使用 Symfony 5 时遇到以下错误
bin/console cache:clear
我知道如何修补 (memory_limit=-1) 但我想知道为什么我会出现这个错误。
错误 :
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)
我无法跟踪此错误的来源。
我从我的项目中删除了所有的 Twig 模板,我手动清除了缓存,但什么都没有......知道吗?
谢谢
最佳答案
它看起来像 bin/console cache:clear
命令占用大量内存。我不认为这是因为 Twig 文件。
设置 memory_limit=-1
有点像您禁用内存限制,这意味着提供无限的内存来运行 PHP。请检查您的 php.ini 文件并调整 memory_limit。
请注意,您可能有 2 个用于 PHP 的 php.ini 文件,一个用于 Web,一个用于命令行。使用 php -i
查看加载的ini文件。
使用此命令 php -i | grep 'Configuration'
从命令行 grep 输出。
关于php - Symfony 5 缓存 :clear php. 关键: fatal error :允许的内存大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59615605/