1

(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.

metrobalderas
  • 5,180
  • 7
  • 40
  • 47
  • 1
    possible duplicate of [Allowed memory size of 33554432 bytes exhausted (tried to allocate 12 bytes)](http://stackoverflow.com/questions/3666315/allowed-memory-size-of-33554432-bytes-exhausted-tried-to-allocate-12-bytes) – mario Mar 13 '11 at 22:30

3 Answers3

6
  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.
Anomie
  • 92,546
  • 13
  • 126
  • 145
  • +1 for straw/camel - if the OP isn't a native english speaker, you may have fun explaining what it means – Mark Baker Mar 13 '11 at 22:30
  • @Mark Baker: Oh, that's easy. "It's an idiom for 'the last small addition that caused the total to exceed a limit and caused catastrophic failure'. See [Wikipedia](http://en.wikipedia.org/wiki/Straw_that_broke_the_camel%27s_back) or [Wiktionary](http://en.wiktionary.org/wiki/the_straw_that_broke_the_camel%27s_back) for a bit more detail." – Anomie Mar 13 '11 at 22:36
  • So `y` = `x` - `request_size`? Thanks a lot. – metrobalderas Mar 14 '11 at 16:36
  • No, `y` is the size of the memory allocation that failed. For example, if there is 1 byte left before exceeding `memory_limit` (which is `x`) and the program tries to allocate 20 bytes, `y` will be 20. – Anomie Mar 14 '11 at 18:14
2

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

dynamic
  • 46,985
  • 55
  • 154
  • 231
0

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.

E.Benoît
  • 796
  • 6
  • 9