title: Why is debug_backtrace() using so much memory?
body: <p>When trying to trace some memory issues in PHP, I noticed that <code>debug_backtrace()</code>, which I call in my logging code, seemed to be using a lot of memory.</p>
  
  <p>In most cases, the following code prints something like <code>0.02 MB</code>. But in one case, it prints <code>171.85 MB</code>!</p>
  
  <pre><code>$before = memory_get_usage();
  $backtrace = debug_backtrace(false);
  $after = memory_get_usage();
  echo round(($after - $before)/1024/1024, 2)." MB";
  </code></pre>
  
  <p>My question is, does this mean that <code>debug_backtrace</code> is actually using that much memory? Or could something else be happening, like garbage collection, that messes up the return value from <code>memory_get_usage</code>?</p>