Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is imagedestroy() required when you only process a single image?

Tags:

php

gd

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?

like image 538
Milan Babuškov Avatar asked Mar 08 '12 18:03

Milan Babuškov


1 Answers

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.

like image 70
Peter Kiss Avatar answered Oct 21 '22 15:10

Peter Kiss