title: Memory leak symfony and monolog and console
body: <p>I spent the last 2 hours trying to find my memory leak. </p>
  
  <ul>
  <li>Optimized the doctrine bulk processing</li>
  <li>Optimized my detach and all that doctrine annotation stuff</li>
  <li>Optimized the SQL Logger</li>
  <li>The script was still leaking</li>
  <li>Decided to comment out the logging because there wasn't much I could do anyway</li>
  </ul>
  
  <p>Turns out that</p>
  
  <ul>
  <li>Over 40k iterations without logging at each n but at modulus 50, start mem: 28 mb end mem: 30mb</li>
  <li>Over 5k iterations with logging at each n, no modulus, start mem:28mb, end mem 38mb. </li>
  </ul>
  
  <p>Example</p>
  
  <pre><code> # this leaks
   # start mem: 28 mb end mem: 38mb, n = 5k
   foreach ($this-&gt;queryData-&gt;iterate() as $j =&gt; $data):
              declare(ticks = 1);
              self::$currentAd++;
              $this-&gt;em-&gt;detach($data[0]);
              $this-&gt;logger-&gt;info(LogUtility::getMemoryUsage() . " (" . self::$currentAd .")");
              if(self::$currentAd === 40000 ):
                  break(2);
              endif;
    endforeach;
  
   # this doesn't leak
   # start mem: 28 mb end mem: 30mb, n = 40k
   foreach ($this-&gt;queryData-&gt;iterate() as $j =&gt; $data):
              declare(ticks = 1);
              self::$currentAd++;
              $this-&gt;em-&gt;detach($data[0]);
              if(self::$currentAd % 50 == 0):
                    $this-&gt;logger-&gt;info(LogUtility::getMemoryUsage() . " (" . self::$currentAd .")");
              endif;
              if(self::$currentAd === 40000 ):
                  break(2);
              endif;
    endforeach;
  </code></pre>
  
  <p>my monolog config:</p>
  
  <pre><code> handlers:
      test:
          type:   stream
          path:   "%kernel.logs_dir%/immobilier/test.log"
          level:  debug
          channels: test
    console:
          type:   console
          bubble: false
          verbosity_levels:
              VERBOSITY_VERBOSE: INFO
              VERBOSITY_VERY_VERBOSE: DEBUG
          channels: [test]
  </code></pre>
  
  <p>Any suggestions to correct this ?</p>