允许的X字节内存已用尽 [英] Allowed memory size of X bytes exhausted

查看:79
本文介绍了允许的X字节内存已用尽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

致命错误:允许的内存大小已用完67108864字节(尝试分配13965430字节)

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 13965430 bytes)

PHPInfo显示我的memory_limit为128M,所以我对为什么错误说我只有64M感到困惑. phpinfo是否有可能错误报告?还是让PHP使用两个单独的php.ini ??

PHPInfo shows that I have a memory_limit of 128M, so I'm confused as to why the error says I only have 64M. Is it possible for phpinfo to report incorrectly? Or for PHP to use two separate php.inis?

该错误是由我的一位同事在我不知情的情况下添加的主要php文件之一中的ini_set调用引起的.

The error was being caused by an ini_set call in one of the primary php files that a co-worker of mine added without my knowledge.

推荐答案

可以在多个位置设置PHP的配置:

PHP's config can be set in multiple places:

  1. 主系统php.ini(通常在/etc中的某个地方)
  2. Apache配置中的某个位置(通过php_value通过httpd.conf或每个站点的.conf文件)
  3. CLI& CGI可以具有不同的php.ini(使用命令php -i | grep memory_limit检查CLI conf)
  4. 本地.htaccess文件(也为php_value)
  5. 脚本内文字(通过ini_set())
  1. master system php.ini (usually in /etc somewhere)
  2. somewhere in Apache's configuration (httpd.conf or a per-site .conf file, via php_value)
  3. CLI & CGI can have a different php.ini (use the command php -i | grep memory_limit to check the CLI conf)
  4. local .htaccess files (also php_value)
  5. in-script (via ini_set())

在PHPinfo的输出中,"Master"值是已编译的默认值,而"Local"值是实际有效的值.它可以与默认值保持不变,也可以在以上任意位置覆盖.

In PHPinfo's output, the "Master" value is the compiled-in default value, and the "Local" value is what's actually in effect. It can be either unchanged from the default, or overridden in any of the above locations.

还要注意,对于命令行和基于Web服务器的操作,PHP通常具有不同的.ini文件.与在基于Web的脚本中运行phpinfo()相比,在命令行中检查phpinfo()将报告不同的值.

Also note that PHP generally has different .ini files for command-line and webserver-based operation. Checking phpinfo() from the command line will report different values than if you'd run it in a web-based script.

这篇关于允许的X字节内存已用尽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆