Re: Do classes/objects need to be destroyed when finished?
| From: | php3 at developersdesk dot com | Date: | Wed, 05 Jul 2000 07:24:27 +0000 |
| Subject: | Re: Do classes/objects need to be destroyed when finished? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-4877@lists.php.net to get a copy of this message | ||
Addressed to: "Michael J. Russell" <mrussell@macomb.com>
php-general@lists.php.net
** Reply to note from "Michael J. Russell" <mrussell@macomb.com> Tue, 4 Jul 2000
15:17:21 -0500
>
> ------=_NextPart_000_0025_01BFE5CA.F31A3A00 Content-Type: text/plain;
> charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
>
> I'm coming from an ASP background to PHP, and one of the things that
> was = always drilled into my head was that I had to destroy objects
> when = finished using them as IIS couldn't be relied upon to release
> the = resources they consume when the script finishes processing. Is
> anything = like this necessary when using objects in PHP?
>
Nope. PHP does a very good job cleaning up after you. Everything goes
away when the script ends, and some things may go away even sooner.
OTOH, if you use something large, early in your script, and never need
it again, you should consider releasing it yourself to save memory.
(unset())
The same for SQL result pointers. If you know you won't use it again,
and you still have lots of other work to do, you can save memory by
releasing them. (mysql_free_result() in MySQL)
If you only do one or two queries, use the results, then terminate the
script, don't worry, PHP will clean up after you just fine.
Rick Widmer
Internet Marketing Specialists
www.developersdesk.com