Answer the question
In order to leave comments, you need to log in
PHP: imagedestroy and unset - what's the difference?
imagedestroy removes the image (the value of a variable of type resource), thus freeing up memory.
unset removes the variable (including the resource type), thus freeing memory.
Those. is it possible to use unset instead of imagedestroy?
Googling didn't turn up anything.
Answer the question
In order to leave comments, you need to log in
The difference can be in how the resource release methods work (the object can be complex) and in the mechanisms of the garbage collector. Especially when you consider that GD is a standalone module and unset is part of the PHP core .
The documentation about the possibility of using unset instead of imagedestroy does not show anything. So it's better to use imagedestroy to avoid memory leaks.
Probably only PHP developers will be able to answer this question, and even then not everyone who participated in the development. PHP versionsthere was already a lot, something in the process could change in logic. Only old-timers who have participated in the development of all versions of PHP and are in their right mind and solid memory can have a complete picture :-)
The source code is open , you can search it :-)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question