title: PHP Imagick memory leak
body: <p>I have to render something with Imagick on PHP CLI.
  I have noticed that every 3-5 days the server memory gets full, so i can't even connet via ssh or ftp.</p>
  
  <p>with memory_get_usage() i narrwoed the memory leak down to the imagick part of the script.
  the script looks something like this:</p>
  
  <pre><code>$sourceImg = 'source.png';
  $destImg = 'dest.png';
  $background ='#00ff00';
  
  $im = new Imagick();
  $im-&gt;pingImage($sourceImg);
  $im-&gt;readImage($sourceImg); 
  $draw = new ImagickDraw();
  
  for($i=1;$i&lt;=5;$i++){
      $draw-&gt;setFillColor( $background);
      $draw-&gt;rectangle( 10*$i+5, 10, 10*$i+10, 20);
  } 
  
  $im-&gt;drawImage( $draw );
  $im-&gt;writeImage( $destImg );
  $im-&gt;destroy();
  
  unset($im,$draw);
  </code></pre>
  
  <p>I destroy the image reference, and unset the imagick and imagickDraw object, but the script won't release any memory. 
  The setFillColor() method takes the most memory</p>
  
  <p>Can i do something else to free the space used by imageick?</p>
  
  <p><a href="https://imgur.com/0xfio" rel="noreferrer">image of the memory consumption</a></p>