Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)
The value of 262,144 bytes is the key to the diagnosis. You'll see this magic number pop up in PHP questions all over the place. Why? Because that is the value PHP will end up with as its memory limit if you attempt to update the limit with a value it can't use. An empty string will produce this memory limit, as will an incorrect unit notation like '128MB' instead of the correct '128M'.
262,144 bytes is exactly 256 Kibibytes. Why PHP runs home to that value when it gets confused is beyond me.
isn't it weird that allowed memory is bigger than allocated memory?
The allocated amount shown is just the most recent allocation attempt, the one that ran afoul of the memory limit. See Allowed memory size in PHP when allocating less.
See if this answer can help you. Particularly the fact that CLI ini could be different than when the script is running through a browser.
Allowed memory size of X bytes exhausted
I see my problem is a little bit different from yours, but I'll post this answer in case it helps someone else. I was using MB
as shorthand instead of M
when defining my memory_limit, and php was silently ignoring it. I changed it to an integer (in bytes) and the problem was solved.
My php.ini changed as follows: memory_limit = 512MB
to memory_limit = 536870912
. This fixed my problem. Hope it helps with someone else's! You can read up on php's shorthand here.
Good luck!
Edit
As Yaodong points out, you can just as easily use the correct shorthand, "M", instead of using byte values. I changed mine to byte values for debugging purposes and then didn't bother to change it back.
In my case neither M
or G
helped, so I have converted allocated memory to bytes using: https://www.gbmb.org/mb-to-bytes
4096M = 4294967296
php.ini:
memory_limit = 4294967296