问题
I'm using PHP to process some image using GD extension. The code structure is rather complicated, images are allocated "deep" in the code and there are many IF's that simply bail-out. The script only processes a single image, and once it writes it to the file it exits.
I guess I could use try...catch instead, but I'm interested to know whether it is really needed to call imagedestroy() or PHP's garbage collector would free it when script ends?
回答1:
No, you don't need to call this function, but it's a good practice because images can be large and if you are in a crowded environment every kilobyte counts.
来源:https://stackoverflow.com/questions/9623260/is-imagedestroy-required-when-you-only-process-a-single-image