Today, PHP (CLI) died with this error:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 58724352 bytes)
(134217728 = 128 MB and 58724352 = 56 MB.)
The file it tried to download was only 73 MB, which is not anywhere near the 128 MB memory limit.
What does it mean by reaching the memory limit of 128 MB? My script's other code doesn't use anywhere near (128 - 73) MB... more like 2-3 MB tops...
And what does it mean by "tried to allocate 56 MB"? Is that referring to 56 MB over the limit? If so, it still doesn't make any sense since, again, 73 MB is already much less than 128 MB.
By the way, increasing the memory limit to 256 MB "fixed" this, as in it downloaded the file without dying or logging any errors, but I'd still like to understand what it means and why it failed when 128 MB should've been more than enough.
PS: Yes, I know that I'm supposed to download large files in chunks, instead of keeping it all in RAM until finished, but the code to do that is simply too complex and annoying* to implement, so right now, I'm just asking about what PHP means by that error and this behaviour.
(*I have put it in my massive "to do" list...)