14

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

2
  • 1
    I am wondering who upvoted this not-a-real-question but it still makes not a slightest sense asking for the "other way" of doing something totally unknown to the reader and stating that "memory limit shouldn't happen" Commented Feb 24, 2012 at 15:14
  • @YourCommonSense, what he means is that the amount his script tried to allocate should be larger than the memory limit in order for the error to exist. Commented May 27, 2021 at 22:53

3 Answers 3

18

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..
Sign up to request clarification or add additional context in comments.

Comments

5

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?

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.