[英]Symfony 4 memory leak when clear cache
I have Symfony app which is built on Symfony 3, but recently I upgraded to Symfony 4. Now I have a problem when clearing cache. 我有基于Symfony 3构建的Symfony应用程序,但是最近我升级到了Symfony4。现在在清除缓存时遇到问题。 When I run command to clear cache I'm getting this error:
当我运行命令清除缓存时,出现此错误:
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32768 bytes) in var/cache/dev/ContainerGGUArAR/getDoctrine_Orm_DefaultEntityManagerService.php on line 85.
PHP致命错误:在第85行的var / cache / dev / ContainerGGUArAR / getDoctrine_Orm_DefaultEntityManagerService.php中,耗尽了536870912字节的内存大小(尝试分配32768字节)。
php.ini memory_limit
is set to -1. php.ini memory_limit
设置为-1。
I found that ServiceEntityRepository
is causing the problem, because when I extend this service to one repository I get this error. 我发现
ServiceEntityRepository
引起了该问题,因为当我将此服务扩展到一个存储库时,会出现此错误。
Does somebody know what should I try to fix it? 有人知道我应该怎么解决吗?
Just to mention that memory_limit
is set also for CLI to be unlimited 只需提及
memory_limit
也设置为CLI不受限制
It is not the solution to the core of your problem but probably allows you to clear the cache even with very large contents: 它不是解决问题核心的方法,但是即使内容很大,也可能允许您清除缓存:
Try 尝试
php -d memory_limit=-1 bin/console cache:clear
or when console is in app/ folder
php -d memory_limit=-1 app/console cache:clear
Or 要么
rm -rf var/cache
or when cache is in app/ folder
rm -rf app/cache
I use "rm" very often instead of the bin/console command. 我经常使用“ rm”而不是bin / console命令。 This does not do any cache warmup so the loading of the first page will take longer.
这不会进行任何缓存预热,因此第一页的加载将花费更长的时间。 Sometimes I get better results clearing cache manually in comparison of the bin/console command...
有时与bin / console命令相比,手动清除缓存会得到更好的结果...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.