3 ms·
Does PHP have similar issues? I think it shouldn't.
by darkhorn 10y ago
Does PHP have similar issues? I think it shouldn't.
- jmcgough 10y agoPHP has garbage collection now, so it's a lot harder to cause a memory leak. Before PHP 5.3.0, cyclical references were one of the biggest causes of memory leaks. However, you can still create memory leaks just like you could in Ruby - dynamic allocation in a c extension that isn't freed up (like in this story), or creating objects that can't be garbage collected (like a slowing expanding array in a global variable).
- lotyrin 10y agoPHP extensions in C are pretty rare since it's so hard to distribute them (outside a few exceptions that exist in common package management systems), so in that sense, I guess? But no, a PHP extension in C can have a memory leak like any other C code. It's not at all uncommon actually, since there are fewer consequences; CGI mode PHP cleans up after every request, FastCGI mode PHP by default restarts workers after a number of requests because of the class of effects (unwanted state) that includes memory leaks.