Fatal error: Allowed memory size in PHP when allocating less

I’m getting this:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried
to allocate 4981690 bytes) in…

That seems a bit odd! From what I can read, it shouldn’t happen should it? Isn’t meant’ to be the other way around. I’m already using a stupidly large memory_limit

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

It doesn’t attempt to allocate it all at once. Let’s say our limit is 10 bytes. It will allocate 3, 3, 3 and another 3 – boom: throws the error:

Allowed memory size of 10 bytes exhausted (tried to allocate 3 bytes) in..

Solution 2

No, it’s allright. The error message might be a mit misleading. The ~5 MB (4981690 bytes) that PHP tried to allocate is not the total amount of memory that PHP allocated. It is just the last bunch of memory that it tried to allocate, which it could not do, because of the memory_limit.

But this really seems like a lot. What are you doing there? Processing many high-res images?

Solution 3

You tried to allocate additional 4981690 bytes, and had already more than 268435456 - 4981690 bytes allocated before.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply