PHP: Memory consumption in different scenarios by counting memory used by PHP (but not allocated to PHP)

There is a question which got me sleepless last night. I was sure about the results but had no real tests. The tests I made today may not be the best but they definitely allowed me to verify my thinking. I was actually trying to find out if the code residing in a PHP function made a difference to memory usage even if the function is not called anywhere.

Long story short, if you want to save some memory from functions which should be globally available but not executed all the time, you may add their code in a different function in a file-to-include when the function is called.

The scenarios' PHP files are found at the following link:
https://gist.github.com/vensires/d2d34b1bbdec99e7c522333d7c620070

Comments

Anonymous said…
Thanks for finally writing about >"PHP: Memory consumption in different scenarios by counting memory used by PHP (but not allocated to PHP)" <Liked it!

Popular Posts