title: Why does PHP's garbage collector slow down performance, and how to manage memory without it?
body: <p>This relates to a PHP 5.3 Cli application that processes a lot of data in a complex way, taking hours to run. Someone discovered that turning off garbage collection made it run a great deal faster (maybe as much as 50%). </p>
  
  <p>The only article I've come across that mentions this performance hit is <a href="http://derickrethans.nl/collecting-garbage-performance-considerations.html">http://derickrethans.nl/collecting-garbage-performance-considerations.html</a>. I'm not sure I follow it entirely, but it seems to suggest that it only applies to code with a lot of circular references.</p>
  
  <p>Could someone shed some light on this please?</p>
  
  <p>Also, given that we have turned gc off, is there any way to manually reduce memory? Using unset() has been suggested. A quick test has shown that eighty or so bytes is freed by unset() regardless of the size of the object. This suggests it's just unsetting the reference, which is borne out by what I have read online. Am I right in thinking that these eighty bytes would be freed anyway, even without garbage collection, when the variable falls out of scope?</p>