note 54095 added to function.imagedestroy

From: Date: Thu, 23 Jun 2005 14:25:05 +0000
Subject: note 54095 added to function.imagedestroy
Groups: php.notes 
Request: Send a blank email to php-notes+get-90842@lists.php.net to get a copy of this message
When working with a lot of high-resolution images, it's IMPERATIVE that you use the imagedestroy() function. In my scenario, I was taking two high resolution desktop wallpapers and shrinking them down into successively smaller ones (preventing the user from having to upload a dozen files). At first, my script would run, then just stop. I realized later that I had not destroyed the source image and the newly resized image in memory after I had finished writing the file out to disk. Thus, I quickly reached the memory limit that my hosting provider placed in their php.ini file. Reusing an image variable does NOT clear the old data out of memory! You must use imagedestroy() to clear the data out. (I don't know if unset() works as well). Also note that the image data in memory is raw, so don't base how much memory you are using based on the original filesize of the compressed image (such as jpeg or png). ---- Manual Page -- http://www.php.net/manual/en/function.imagedestroy.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54095 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54095&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54095&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54095&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54095&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54095&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54095&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54095&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90842) next »