php CakePHP:致命错误:允许的内存大小为 536870912 字节已用完(尝试分配 52 字节)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20650692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CakePHP : Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 52 bytes)
提问by Asfaq Tamim
Hi i have a apps running on CakePHP v 1.3. I've updated my wampserver to v2.4.After updating i got this error message.I did these changes into my php.ini settings.
嗨,我有一个应用程序正在运行CakePHP v 1.3。我已将我的wamp服务器更新为v2.4. 更新后我收到此错误消息。我对 php.ini 设置进行了这些更改。
- memory_limit = 128M
- file_uploads = ON
- upload_max_filesize = 128M
- max_input_time
- max_execution_time = 300
- post_max_size = 128M
- realpath_cache_size = 16k
- realpath_cache_ttl = 120
- 内存限制 = 128M
- file_uploads = ON
- 上传最大文件大小 = 128M
- 最大输入时间
- 最大执行时间 = 300
- post_max_size = 128M
- realpath_cache_size = 16k
- realpath_cache_ttl = 120
But i'm still getting these Error message :
但我仍然收到这些错误消息:
CakePHP : Fatal error: Allowed memory size of 536870912 bytes exhausted
(tried to allocate 52 bytes) in C:\wamp\www\gtgcrm\cake\libs\model\
datasources\dbo\dbo_mysql.php on line 775
What i missed ? Any Suggestion will be appreciated !
我错过了什么?任何建议将不胜感激!
采纳答案by Anubhav
You can increase memory limit by using in your controller action
您可以通过在控制器操作中使用来增加内存限制
ini_set('memory_limit', '256M');
Also you can increase time out limit
您也可以增加超时限制
set_time_limit(0); Infinite
回答by Girish
Increase memory limit in php.ini, this is not is appropriate solution at all.
增加内存限制php.ini,这根本不是合适的解决方案。
this case can be also occurred from code e.g infinite loop, process large amount data, or even database queries You should check code, there might have been infinite loop or such type case.
这种情况也可能发生在代码中,例如无限循环,处理大量数据,甚至数据库查询您应该检查代码,可能存在无限循环或此类类型的情况。
回答by Moyed Ansari
The error is obvious and it is due to exceeding memory limits by setting in your ini files or .htaccess. You can also set via php as Anubhay wrote. Following variables are your concern
该错误很明显,这是由于在您的 ini 文件或 .htaccess 中设置超出了内存限制。您也可以通过 php 进行设置,如 Anubhay 所写。以下变量是您所关心的
php_value post_max_size 1000M
php_value upload_max_filesize 2500M
php_value max_execution_time 6000000
php_value max_input_time 6000000
php_value memory_limit 2500M
You can optimize query data by using cake behavior containable. It is better practice to optimize your code/data rather than increasing memory size.
您可以使用可包含的蛋糕行为来优化查询数据。优化代码/数据而不是增加内存大小是更好的做法。
Thanks
谢谢
回答by Indrajeet Singh
Try...
Allowed memory size
ini_set('memory_limit', '-1');

