do i need to use imagedestroy() in this loop?
I'm using the same variable to create a lot of images, so each one overrides the previous one. D开发者_Go百科o I need to use imagedestroy()
?
ex:
<?php
foreach($paths as $path) {
$image = imagecreatefrompng($path);
//more code...
imagedestroy($image); //--------> should i do this?
}
imagedestroy($image); //---------> or should i do this?
Depending on what you are doing exactly you should put imagedestroy()
within the loop to free the memory and make space for the next images. On the other hand it just doesn't hurt
精彩评论