英文:
Symfony 5 cache:clear php.CRITICAL: Fatal error: Allowed memory size
问题
Here's the translated content:
我在尝试运行Symfony 5时遇到以下错误:
bin/console cache:clear
我知道如何修复这个问题(memory_limit=-1),但我想知道为什么会出现这个错误。
错误信息:
> PHP致命错误:已用尽134217728字节的内存限制
>(试图分配32230840字节)
> 位于/Applications/MAMP/htdocs/Toile./vendor/twig/twig/src/Lexer.php的第157行
>
>15:50:13 CRITICAL [php] 致命错误:已用尽134217728字节的内存限制(试图分配32230840字节)
>
> [
> "exception" => Symfony\Component\ErrorHandler\Error\OutOfMemoryError {
> -error: [
> "type" => 1,
> "message" => "已用尽134217728字节的内存限制(试图分配32230840字节)",
> "file" => "/Applications/MAMP/htdocs/Toile./vendor/twig/twig/src/Lexer.php",
> "line" => 157
> ]
> #message: "错误:已用尽134217728字节的内存限制(试图分配32230840字节)"
> #code: 0
> #file: "./vendor/twig/twig/src/Lexer.php"
> #line: 157
> }
> ]
>
> 在Lexer.php的第157行:错误:已用尽134217728字节的内存限制(试图分配32230840字节)
我无法确定这个错误是从哪里引起的。
我从项目中删除了所有twig模板,手动清除了缓存,但仍然没有解决。有任何想法吗?
谢谢
英文:
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
得分: 3
"看起来bin/console cache:clear
命令占用了大量内存。我不认为这是因为twig文件。\n\n设置memory_limit=-1
有点像是禁用了内存限制,意味着给予PHP无限制的内存运行。请检查您的php.ini文件并调整memory_limit。\n\n请注意,您可能有两个PHP的php.ini文件,一个用于Web,一个用于命令行。使用php -i
查看加载的ini文件。\n\n使用此命令php -i | grep 'Configuration'
来从命令行中提取输出。"
英文:
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.
答案2
得分: 0
检查您的项目目录,看看是否有一些代码不包含任何类似这样的行:ini_set('memory_limit'
。Symfony会解析所有类并考虑它。例如,在我的情况下,有:ini_set('memory_limit', '42M');
,而42MB不足以运行控制台任务。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论