Re: Unsetting vars when not needed?

From: Date: Fri, 12 Nov 2004 14:23:15 +0000
Subject: Re: Unsetting vars when not needed?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-201846@lists.php.net to get a copy of this message
I use mysql_free_result when I'm done with the particular query, but I don't really bother unsetting things unless I'm doing something that is using a lot of memory. PHP will clear everything at the end of the run anyway. I guess technically it's garbage collection, but PHP is wiping everything, so it doesn't have the overhead of checking what's been used, still in use or expired. It's just a wipe. Unsetting is a good coding habit to get into, but I'm not sure of the performance benefits. There are lots of others areas I would focus on first to get better performance, like minimizing the number of connections you need to make to mysql, optimizing your queries, output buffering, etc. On Nov 12, 2004, at 8:53 AM, Jordi Canals wrote:
Hi all, I was working now in a new site developed with PHP 5.0.2 and a wonder came to me: Is usefull and recommended to unset a class instance when not needed? Specially when the class was instantiated inside a function and the function ends. In this case, the system should automatically destroy the instance (as it is a local var inside a function). If we manually unset the instance at the end of the function, does this affect the PHP performance? I mean, will PHP have to do an extra job unsetting the var? Also, the same question arises with database results. Is it worth to call mysql_free_result at the end of a function that uses it? Must take into consideration that there are lots of functions that use lots of MySQL results. Thanks for any comment Jordi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577


« previous php.general (#201846) next »