metrobalderas
metrobalderas

Reputation: 5240

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.

Upvotes: 1

Views: 5698

Answers (3)

Anomie
Anomie

Reputation: 94844

  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.

Upvotes: 6

E.Benoît
E.Benoît

Reputation: 806

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.

Upvotes: 0

dynamic
dynamic

Reputation: 48141

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

Upvotes: 2

Related Questions