是什么限制了我的PHP资源? [英] What's limiting my PHP resources?
问题描述
我在从PHP获取更多内存方面遇到问题.
I'm having a problem getting more memory out of PHP.
这是错误消息:
Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 82 bytes) in ...
但是:
我已将php.ini文件中的memory_limit设置为32M:
I've set memory_limit in the php.ini file to 32M:
memory_limit = 32M;
我还尝试在实际脚本中手动覆盖它:
I've also tried to override it manually in the actual script:
ini_set('memory_limit', '32M');
而且-这是我迷路的地方-我已通过phpinfo()确认此php.ini文件是所使用的实际ini文件,并且memory_limit似乎设置正确. memory_limit上的这一行给出了这一点:
And -- here's where I'm lost -- I've confirmed via phpinfo() that this php.ini file is the actual ini file used, and the memory_limit seems to be set correctly. The line on memory_limit gives this:
memory_limit 32M 32M
因此,似乎所有配置都正确,但是我只能得到20971520字节(〜20M).
So it would seem that everything is configured properly, but I'm only getting 20971520 bytes (~20M).
我还应该在哪里寻找施加此限制的地方?
Where else should I be looking to figure out where this limitation is being imposed?
编辑:我正在VPS上的Ubuntu 9.04上的nginx/fastcgi下运行php. php-cgi进程似乎确实有点资源紧张(RES = 25m,VIRT = 187m),但是我有10m的物理内存可用空间和500m的交换空间可用.
I'm running php under nginx/fastcgi, on Ubuntu 9.04 in a VPS. The php-cgi processes do seem to be a bit resource-hungry (RES=25m, VIRT=187m), but I have 10m of physical memory free and 500m of swap space free.
推荐答案
我只是仔细研究了正在运行的代码,并且有人将其硬编码为配置文件:
I just pored over the code I was running, and someone had hard-coded this into a config file:
ini_set('memory_limit', '20M');
那是我正在做的所有事情的重中之重.哇.
Which was overriding everything else I was doing. Whew.
这篇关于是什么限制了我的PHP资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!