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:
- This is obviously an out-of-memory error, but what does it means in Layman's terms?
- Is it possible to know some information (like server's RAM) from
x
? - What about
y
? Sometimes it is a two-digits number.
Thanks.
- 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. x
gives you the value of thememory_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.- 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.
精彩评论