开发者

Meaning of "Fatal error: Allowed memory size of x bytes exhausted (tried to allocate y bytes)"?

(This is a very开发者_开发技巧 frequent error, but couldn't find the meaning.)

Fatal error: Allowed memory size of x bytes exhausted (tried to allocate y bytes)

I have some questions:

  1. This is obviously an out-of-memory error, but what does it means in Layman's terms?
  2. Is it possible to know some information (like server's RAM) from x?
  3. What about y? Sometimes it is a two-digits number.

Thanks.


  1. It means that the memory used by the PHP script exceeded the value of the memory_limit configuration option. Note this may or may not agree with what the operating system thinks the memory usage of the script is at the time of the error.
  2. x gives you the value of the memory_limit configuration option. You can also assume that the server has at least enough virtual memory to handle the limit, but that's about it.
  3. No, y is just the size of the straw that finally broke the camel's back.


x = ini_get('memory_limit');

y = the php request that exceed that limit

The ram here isn't a problem, make a better php script or just rise memory_limit with ini_set

Anyway your question is a dup and a simple google search would solved it


This error is triggered because the PHP interpreter has a memory size limit for the scripts it runs. The "x" part is that limit, "y" is the allocation that caused the script to trigger the error. To override this, you can use either something like:

php_value memory_limit xxxM

in your server configuration or

memory_limit = xxxM

in the PHP configuration or

ini_set('memory_limit', 'xxxM');

in the script itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜