In my early days of programming I often used to get memory related fatal errors in the following format:Fatal error: Allowed memory size of <some big number> bytes exhausted (tried to allocate <some small number> bytes) in /path/to/filename.php on line <some line number>I'm a little embarrassed to state that even though I have figured out how to solve them and take steps to avoid them altogether, I'm still not quite sure what exactly does the message translate to in simple words.For example, if I get a message such as:Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4000 bytes) in ........ on line 34As things stand at the moment, I assume it to be stating that the script consumes 67108864 bytes of data, but only 4000 bytes are available during runtime.Am I right in my assumption?If not, what's the correct interpretation?
Failed to allocate memory - What is it trying to say?
php;memory
Your program has 67108864 bytes (~67MB) available to it at runtime, all of which it has filled. The specific allocation which took the total memory usage from <67MB to >67MB was an allocation of 4000 bytes, which happened within the expression on line 34.Basically, you're using too much memory, and all the interpreter can give you to help is the specific allocation which broke the camel's back. It could have been a one byte allocation, all that matters is that it took you over your memory limit.