Re: [PHP] destructor sequence explained




----- Original Message ----- From: "Richard Lynch" <ceo@xxxxxxxxx>
To: "james james" <php.james@xxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Wednesday, February 28, 2007 1:33 AM
Subject: Re: [PHP] destructor sequence explained


On Tue, February 27, 2007 6:11 pm, james james wrote:
Can someone please help explain how the order of object destructors
called
at shutdown is determined, especially with regards to objects composed
of other objects?

I think that changed from version to version, so unless you are on a
dedicated server, you have to manage any order dependencies for
yourself...

I do not think there *IS* a documented ordering to this.


Actually, I think it is documented that the order of the destructors cannot be predicted. This means that even if you find how it is done in this particular version, don't count on that to hold if in a newer version they change it. By stating that it cannot be predicted, the developers reserve the right to change it at any time.

When an object is deleted, it is put in the list of things to be dispossed of, and the garbage collector will call the destructors prior to deallocating the memory. It can happen at any time when there is no higher priority stuff to be done. So, it all depends on the whim of the garbage collector, a background item that the developers might change at any time and whose behaviour depends on lots of unpredictable things such as server load.

You get whatever order PHP feels like using.

exactly

Satyam


--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.4/703 - Release Date: 26/02/2007 14:56


.



Relevant Pages

  • Re: Garbage collection
    ... I'm building a server with python, but coming from a c++ background, garbage collection seems strange. ... When those objects are no longer needed, I use del manager, hoping to force the garbage collector to perform the delete. ... My guess is that you might not even need to overload __del__ at all. ... People from a C++ background often mistakenly think that they have to write destructors when in fact they do not. ...
    (comp.lang.python)
  • Re: Structured Exception Handling (was: Try Finally...)
    ... IMO the possibly delayed execution of destructors is a property of languages ... I remember an article "Why a garbage collector should not call destructors" by ... >is much more rigid and is guaranteed to run in the same chain traversal ... Where did you find such a guarantee? ...
    (comp.lang.pascal.delphi.misc)
  • Re: Why We Use C Than C++...
    ... >>>garbage collector, ... >> destructors can perform any arbitrary cleanup actions (closing files, ... it is easy to do automatic cleanups ... The exception handling provided by ...
    (comp.lang.c)
  • Re: CLOS question
    ... called at all (because a garbage collector cannot guarantee to ever ... This means that destructors don't provide ... give a pseudo-code explanation maybe? ...
    (comp.lang.lisp)
  • Destroying Objects
    ... destructors for objects. ... I know that PHP doesn't supply an object ... but it shuts down at the end of the session regardless of whether I plan to ...
    (comp.lang.php)