note 28950 added to function.imagedestroy

From: Date: Wed, 29 Jan 2003 01:41:09 +0000
Subject: note 28950 added to function.imagedestroy
Groups: php.notes 
Request: Send a blank email to php-notes+get-42956@lists.php.net to get a copy of this message
Whenever I use GD, this is at the top of every file: <? //NOTE: ALL IMAGE RESOURCE IDENTIFIERS MUST GO INTO $DESTROY ARRAY! //THIS SHUTDOWN FUNCTION CLEANS UP MEMORY LEAKED BY THE GD LIBRARY! register_shutdown_function("destroy_images"); function destroy_images() { foreach($GLOBALS['DESTROY'] as $IM) imagedestroy($IM); } $DESTROY=array(); ?> Then, <? $DESTROY[]=$im=imagecreate($x,$y); ?> Every time I make an image, so the shutdown function automatically cleans for up every image created through the library. Perhaps this feature could be added to PHP? -- http://www.php.net/manual/en/function.imagedestroy.php http://master.php.net/manage/user-notes.php?action=edit+28950 http://master.php.net/manage/user-notes.php?action=delete+28950 http://master.php.net/manage/user-notes.php?action=reject+28950

« previous php.notes (#42956) next »