RE: [PHP] Do classes/objects need to be destroyed when finished?
| From: | Howard Cohodas | Date: | Wed, 05 Jul 2000 19:59:55 +0000 |
| Subject: | RE: [PHP] Do classes/objects need to be destroyed when finished? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5053@lists.php.net to get a copy of this message | ||
Configuration:
OS - NT4SP6a
HTTP - WebSite Pro 2.4.22
PHP - 4.0.1pl2
I invoke via COM an object built as an ActiveX dll with MS VB. Everything
is fine in ASP. The first time I run the script there is no error.
Subsequent times I get the following.
Warning: Unable to obtain IDispatch interface for CLSID
{15DBEE96-4F98-11D4-8993-0000C07514EE}: CoInitialize has not been called. in
D:\Web_Sites\Testing_PHP4\HTdocs\test_com.php4 on line 9
Unable to instanciate object
Unset did not fix the problem. The only way to run again is to stop and
restart the HTTP server.
Howard A. Cohodas
Design Knowledge Technologies Inc.
Phone: (011)(330)492-9900
FAX: (011)(330)492-1100
otfGIF Encoder: http://www.dkt.com/otfGIF
-----Original Message-----
From: php3@developersdesk.com [mailto:php3@developersdesk.com]
Sent: Wednesday, July 05, 2000 3:24 AM
To: Michael J. Russell; php-general@lists.php.net
Subject: Re: [PHP] Do classes/objects need to be destroyed when
finished?
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net