简体   繁体   English

Symfony清除缓存内存限制

[英]Symfony clear cache memory limit

Here's my problem: when I try to execute the cache:clear command in my dev environment, I have a fatal error because of the PHP memory limit. 这是我的问题:当我尝试在开发环境中执行cache:clear命令时,由于PHP内存限制,我出现了致命错误。 So, I tried to increase this limit to 2048M, which should be enough, but still the same issue. 因此,我试图将这个限制增加到2048M,这应该足够,但是仍然是相同的问题。

I tried everything: manually deleting the cache folder before executing the command, set the PHP memory_limit to -1 (stopped by Windows because it was out of memory to allocate), executing the command with --no-warmup or --no-optional-warmers... 我尝试了所有操作:在执行命令之前手动删除缓存文件夹,将PHP memory_limit设置为-1(由于已分配内存不足,Windows停止了该操作),使用--no-warmup或--no-optional执行命令-暖和的...

For information, everything else works like a charm... 对于信息,其他所有东西都像个魅力一样...

Why this command is so greedy? 为什么这个命令这么贪心? And how can I solve my problem? 我该如何解决我的问题?

Thanks! 谢谢!

Where did you change the memory limit. 您在哪里更改了内存限制。

There is a big chance your php.ini is different for web server and command line Interface(CLI). 对于网络服务器和命令行界面(CLI),您的php.ini很有可能会有所不同。

If you face the problem of memory limit in command line, make sure you are edit the correct php.ini file. 如果您在命令行中遇到memory limit问题,请确保您编辑了正确的php.ini文件。

To know what are the ini files are in used. 要知道使用了哪些ini文件。 run the command : php --ini 运行命令: php --ini

Hope this helps. 希望这可以帮助。

I had similar problem when I was upgrading from SF2.3 to SF2.8 (lot of BC changes). 从SF2.3升级到SF2.8(很多BC更改)时,我遇到了类似的问题。 PHP scripts run via CLI doesn't have max memory restriction set by default. 默认情况下,通过CLI运行的PHP脚本没有设置最大内存限制。 That is why all memory resources are being used up. 这就是为什么所有内存资源都被用完的原因。

Problem went away after I: 问题在我之后消失了:

  1. upgraded bundles to more recent version, which were probably not compatible enough with recent SF version at the time. 将捆绑软件升级到了较新的版本,这可能与当时的SF版本不兼容。

  2. Fixed all my code to reflect BC changes from upgrade manual (mostly form types, yaml settings and controllers). 修复了我所有的代码,以反映升级手册中BC的更改(主要是表单类型,yaml设置和控制器)。

Bundles and my code were producing a lot more debug information (usually deprecation warnings), which caused PHP Xdebug to take up all the resources until memory maxed out. 捆绑软件和我的代码产生了更多的调试信息(通常是弃用警告),这导致PHP Xdebug占用了所有资源,直到内存用尽。 I noticed that only while warming up cache. 我注意到这只是在预热缓存时。 After all the fixes I kept warning messages to minimum. 修复所有问题后,我将警告消息降至最低。

You could check: 您可以检查:

  • dev.log for any deprecation warnings dev.log中是否有任何弃用警告
  • xdebug settings and set max_nesting_level to some sane value: xdebug.max_nesting_level=1200 xdebug设置并将max_nesting_level设置为一些合理的值: xdebug.max_nesting_level = 1200
  • disable xdebug for CLI, which is unnecessary anyway: php5dismod -s cli xdebug 禁用xdebug的CLI,反正这是不必要的: php5dismod -s cli xdebug

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM