Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16199 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27040 invoked by uid 1010); 10 May 2005 15:12:22 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 3294 invoked from network); 10 May 2005 14:49:13 -0000 Received: from unknown (HELO suserver.com) (127.0.0.1) by localhost with SMTP; 10 May 2005 14:49:13 -0000 X-Host-Fingerprint: 200.32.3.79 200-32-3-79.prima.net.ar Linux 2.4/2.6 Received: from ([200.32.3.79:40489] helo=mail.bpservers.com.ar) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id 90/34-35155-6E9C0824 for ; Tue, 10 May 2005 10:49:12 -0400 Received: (qmail 6190 invoked by uid 0); 10 May 2005 14:49:07 -0000 Received: from unknown (HELO ?192.168.0.240?) (200.42.80.195) by 200-32-3-79.prima.net.ar with SMTP; 10 May 2005 14:49:07 -0000 Reply-To: lpedretti@suserver.com Organization: Axon Sistemas To: Lukas Smith Date: Tue, 10 May 2005 11:48:56 -0300 User-Agent: KMail/1.7.2 References: <200505091130.56300.lpedretti@suserver.com> <200505101046.19099.lpedretti@suserver.com> <4280C47B.2070507@php.net> In-Reply-To: <4280C47B.2070507@php.net> Cc: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-ID: <200505101148.56888.lpedretti@suserver.com> Subject: Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object From: lpedretti@suserver.com (Leonardo Pedretti) Yes, the question was pointed in another way, the destructors are not calle= d=20 until the last reference to an object has been removed, but if you store a= =20 reference in an array so you lately return a reference to the already loade= d=20 instance instead of creating an aliasing of that instance, then you get the= =20 undesirable behavior that the object is never destroyed until the script=20 ends, because there is always a reference in that array and you can not che= ck=20 when references are removed in any way. And leaving the array growing while each object that exists in a huge datab= ase=20 is slowly loaded and never unloaded, is not an option. Leo On Tuesday 10 May 2005 11:26, you wrote: > Leonardo Pedretti wrote: > > It would not be such a problem to write something that does the same ta= sk > > through a static or global function, but unfortunately it is impossible, > > due to the following: you can build a cache in an array, then in a > > __new() function you could check if the requested object is already > > loaded and return a reference. However, if this is the case, objects th= at > > enter the cache never leave it because they are still referenced in the > > array when all other references have gone, so they never destruct, exce= pt > > when the array is destroyed at program's end. > > PHP5 has destructors ... > > regards, > Lukas =2D-=20 Leonardo Pedretti Axon Sistemas L=EDder de Equipo Proyecto Basalto