I’m using the same variable to create a lot of images, so each one overrides the previous one. Do 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