Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31531 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91751 invoked by uid 1010); 10 Aug 2007 23:01:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 91731 invoked from network); 10 Aug 2007 23:01:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2007 23:01:49 -0000 Authentication-Results: pb1.pair.com header.from=nathanael@gnat.ca; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=nathanael@gnat.ca; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gnat.ca from 24.71.223.10 cause and error) X-PHP-List-Original-Sender: nathanael@gnat.ca X-Host-Fingerprint: 24.71.223.10 shawidc-mo1.cg.shawcable.net Received: from [24.71.223.10] ([24.71.223.10:23779] helo=pd2mo1so.prod.shaw.ca) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/E1-12916-B5EECB64 for ; Fri, 10 Aug 2007 19:01:49 -0400 Received: from pd2mr6so.prod.shaw.ca (pd2mr6so-qfe3.prod.shaw.ca [10.0.141.9]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JMK00L5LYM6QTD0@l-daemon> for internals@lists.php.net; Fri, 10 Aug 2007 17:01:18 -0600 (MDT) Received: from pn2ml4so.prod.shaw.ca ([10.0.121.148]) by pd2mr6so.prod.shaw.ca (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) with ESMTP id <0JMK000DRYM63900@pd2mr6so.prod.shaw.ca> for internals@lists.php.net; Fri, 10 Aug 2007 17:01:18 -0600 (MDT) Received: from iridium.gnat.ca ([68.147.43.155]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JMK000B2YM5ZGJ6@l-daemon> for internals@lists.php.net; Fri, 10 Aug 2007 17:01:17 -0600 (MDT) Date: Fri, 10 Aug 2007 17:01:17 -0600 To: internals@lists.php.net Message-ID: <46BCEE3D.7080103@gnat.ca> Organization: Gnat Solutions, Inc MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit User-Agent: Thunderbird 2.0.0.5 (X11/20070719) Subject: Pre-Destructor magic function? From: nathanael@gnat.ca ("Nathanael D. Noblet") Hello, I have a case where an object has a few variables, a couple of which are objects which hold references back to this object. So very simply something like class A { var B } class B { var A } When doing something like so $obj = new A(); in a loop the object's never released from memory because of the internal references it holds. __destruct is not called until the end of script execution etc. Now normally in a web request situation this isn't a big deal. However I'm using it in a batch and loop over 22 000 records. Since re-assigning the single object I use isn't freeing any memory it consumes quite a bit. I have gotten around it by creating a special function in the object to manually release the recursive references. However it would be nice if there were some sort of 'magic' function that could be called on an object so that it knows it is being deleted, sort of like a __preDestruct or something like that... Is that a bad idea? Or I guess better able to handle recursive references in objects would be the other way to solve it I guess. Any feedback is welcome. -- Nathanael D. Noblet