I did a quick and dirty test, image1 - 85kb image2 - 457kb
$start = microtime(); for($i=0; $i<10; $i++){ $img = new Imagick('./image1.jpg'); $img->setImageResolution(72,72); $img->resampleImage(72,72,imagick::FILTER_UNDEFINED,0); $img->destroy(); $img = new Imagick('./image2.jpg'); $img->setImageResolution(72,72); $img->resampleImage(72,72,imagick::FILTER_UNDEFINED,0); $img->destroy(); } $end = microtime(); $len = $end - $start; echo number_format($len, 2),'<br /> <br />'; function kb($n){ return ceil($n/1024); } echo 'memory usage - ',kb(memory_get_usage()),' / ',kb(memory_get_peak_usage()),' <br />';
And then I commented out the destruction lines and ran it again. it seemed strange that using destroy() uses more memory, but only 3 or 4 k. the timer was no different, and when I ran the basic load test on the apache platform
ab -n 20 -c 5 http://ubunty.local/sandbox/stackexchange/imagick.php
It did not seem to have much.
I expected to destroy less memory. even using image2 in another variable doesn't seem to matter
$img2 = new Imagick('./image2.jpg');
If there is a reason to use โ destroy (), then as far as I can tell, this should be to the point that I forgot to measure.
source share