I did a quick and dirty test, image1 is 85kb image2 is 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 destroy lines, and ran it again. strangely it seemed to use more memory when using destroy()
but only 3 or 4 k. the timer didn't show much different, and when I ran a basic apache bench load test
ab -n 20 -c 5 http://ubunty.local/sandbox/stackexchange/imagick.php
There didn't seem to be much in it.
I was expecting destroy to use less memory. even using image2 in a different variable didn't seem to make a difference
$img2 = new Imagick('./image2.jpg');
If there is a reason to use ->destroy() then it must be down to something I forgot to measure, as far as I can see.