You can’t walk ten steps in this businesses without hearing Engineering is a set of tradeoffs. You rarely hear the other side of that: and sometimes we make the wrong tradeoffs which lead to living with garbage behavior for years.
PHP leaks memory like a sieve. By leak we mean during a long running PHP request the amount of memory will slowly increase over time because there’s some memory the garbage collector can’t free up. The usual response to this is a shrug, and mumbling some words about PHP’s process model taking care of this. i.e. PHP doesn’t have many long running requests so the leaks are an accepable tradeoff.
Until, of course, you have that long running import script, or your server’s getting a bunch of traffic that’s trashing your memory which in turn thrashes the CPU. Then you’re left with a the near impossible task of guessing which object instantiations are the ones PHP’s garbage collector can’t free up.
The new PHP Meminfo extesion isn’t a pancea, but it does look like a tool that can help you pinpoint which object references are the problem, and put you in a better position to deal with them. Also, burried in the repo is a link to some slides that have the most cogent explaination I’ve seen lately of why PHP has these sort of userland memory leaks. (The preseataion of these slides is probalby great, but I live in a second-and-a-half-world country and wasn’t taught French)
PHP Meminfo v1.0.0 released !
– PHP 7.x support
– better summary feature
– better docLet's hunt down some memory leaks!https://t.co/hhj8NEnqLO#PHPMeminfo #PHP #performances
Thanks @RomainMonceau, @jujanvier, @FrancisBesset and Niktux for your contributions!
— Benoit Jacquemont (@BJacquemont) November 16, 2017