开发者

do i need to use imagedestroy() in this loop?

开发者 https://www.devze.com 2023-03-30 12:36 出处:网络
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()?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消