title: php daemon possible memory leak
body: <p>i've written a daemon in php and want to make sure it doesn't leak memory, as it'll be running 24/7.</p>
  
  <p>even in its simplest form memory_get_peak_usage for a daemon will report that the script consumes more memory for each cycle. memory_get_usage on the other hand will not grow.</p>
  
  <p>the question is: should i worry? i've stripped down the daemon to the bare basics but this is still happening. any thoughts?</p>
  
  <pre><code>#!/usr/bin/php -q
  
  &lt;?php
  require_once "System/Daemon.php";
  System_Daemon::setOption("appName", "smsd");
  System_Daemon::start();
  while(!System_Daemon::isDying()){
   System_Daemon::info("debug: memory_get_peak_usage: ".memory_get_peak_usage());
   System_Daemon::info("debug: memory_get_usage: ".memory_get_usage());
   System_Daemon::iterate(2);
  }
  </code></pre>
  
  <p>FINAL NOTE + CONCLUSION: i ended up writing my own daemon wrapper, not using pear's system_daemon. regardless of how i tweaked this library i could not stop it from leaking memory. hope this helps someone else.</p>
  
  <p>FINAL NOTE + CONCLUSION 2: my script has been in production for over a week and is still not leaking 1 bytes of memory. so - writing a daemon in php actually seems to be ok, as long as you're very careful about its memory consumtion.</p>