Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31539 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31508 invoked by uid 1010); 12 Aug 2007 05:42:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 31493 invoked from network); 12 Aug 2007 05:42:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2007 05:42:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain l-i-e.com from 67.139.134.202 cause and error) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:2010] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/01-08687-8CD9EB64 for ; Sun, 12 Aug 2007 01:42:34 -0400 Received: (qmail 73213 invoked by uid 98); 12 Aug 2007 05:42:37 -0000 Received: from 127.0.0.1 by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.01 (clamdscan: 0.88.7/3923. Clear:RC:1(127.0.0.1):. Processed in 0.074952 secs); 12 Aug 2007 05:42:37 -0000 Received: from localhost (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 12 Aug 2007 05:42:37 -0000 Received: from 209.254.223.2 (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Sun, 12 Aug 2007 00:42:37 -0500 (CDT) Message-ID: <55685.209.254.223.2.1186897357.squirrel@www.l-i-e.com> In-Reply-To: <46BCEE3D.7080103@gnat.ca> References: <46BCEE3D.7080103@gnat.ca> Date: Sun, 12 Aug 2007 00:42:37 -0500 (CDT) To: "Nathanael D. Noblet" Cc: internals@lists.php.net Reply-To: ceo@l-i-e.com User-Agent: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] Pre-Destructor magic function? From: ceo@l-i-e.com ("Richard Lynch") On Fri, August 10, 2007 6:01 pm, Nathanael D. Noblet wrote: I'm not a PHP OOP expert, so this could be 100% wrong, but... > $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 If __destruct isn't being called until the end of the script, then PHP thinks you still have some way of accessing that object, and it can't free it. > 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. Perhaps set some things to NULL or unset them explicitly to convince PHP that you are done with them. > I have gotten around > it by creating a special function in the object to manually release > the > recursive references. Well, there you go. Release the references so PHP knows you are done with them. > 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. __destruct is called right before PHP destroys the object. There really isn't any event of any significance for a __perDesctruct... Either you're done with it, or you're not... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?