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

David
  • 16,246
  • 34
  • 103
  • 162
  • 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" – Your Common Sense Feb 24 '12 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. – Keyslinger May 27 '21 at 22:53

3 Answers3

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..
Wesley van Opdorp
  • 14,888
  • 4
  • 41
  • 59
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?

Carsten
  • 17,991
  • 4
  • 48
  • 53
1

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

Basti
  • 3,998
  • 1
  • 18
  • 21