Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31533 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89950 invoked by uid 1010); 11 Aug 2007 06:28:35 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89935 invoked from network); 11 Aug 2007 06:28:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2007 06:28:35 -0000 Authentication-Results: pb1.pair.com header.from=info@adaniels.nl; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=info@adaniels.nl; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain adaniels.nl from 82.94.236.173 cause and error) X-PHP-List-Original-Sender: info@adaniels.nl X-Host-Fingerprint: 82.94.236.173 loco.helderhosting.nl Linux 2.5 (sometimes 2.4) (4) Received: from [82.94.236.173] ([82.94.236.173:51459] helo=loco.helderhosting.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/50-19275-E075DB64 for ; Sat, 11 Aug 2007 02:28:32 -0400 Received: from [192.168.2.13] (bas3-toronto01-1177780003.dsl.bell.ca [70.51.127.35]) by loco (Postfix) with ESMTP id D7E692C5F9F; Sat, 11 Aug 2007 08:28:27 +0200 (CEST) Message-ID: <46BD5725.10201@adaniels.nl> Date: Sat, 11 Aug 2007 02:28:53 -0400 User-Agent: Thunderbird 1.5.0.12 (X11/20070604) MIME-Version: 1.0 To: "Nathanael D. Noblet" Cc: internals@lists.php.net References: <46BCEE3D.7080103@gnat.ca> In-Reply-To: <46BCEE3D.7080103@gnat.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Pre-Destructor magic function? From: info@adaniels.nl (Arnold Daniels) Hi Nathanael, If you've been watching the list you could have seen that David Wang (god bless his soul) is working on this at the moment. Have a look at http://marc.info/?l=php-dev&m=118418663902191&w=2. You'll have to stick with your custom solution for now though. Best regards, Arnold Nathanael D. Noblet wrote: > 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. >