Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19940 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12033 invoked by uid 1010); 10 Nov 2005 03:40:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 12018 invoked from network); 10 Nov 2005 03:40:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Nov 2005 03:40:16 -0000 X-Host-Fingerprint: 198.237.84.92 unknown Linux 2.4/2.6 Received: from ([198.237.84.92:1489] helo=bobsilva.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 4A/4B-28724-D11C2734 for ; Wed, 09 Nov 2005 22:40:14 -0500 Received: from [198.237.84.93] (HELO jake) by bobsilva.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 678549 for internals@lists.php.net; Wed, 09 Nov 2005 16:20:23 -0800 To: Date: Wed, 9 Nov 2005 19:38:00 -0800 Message-ID: <001601c5e5a8$264d6540$5d54edc6@jake> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0017_01C5E565.182A2540" X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Thread-index: AcXlqCYgaJkIXFoURiGuslvtJ3ypOg== Subject: Good memory management From: me@bobsilva.com ("Bob Silva") ------=_NextPart_000_0017_01C5E565.182A2540 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, Got a question on proper memory management within the engine. I have an object that stores an Array (IS_ARRAY) as a property. Inside this property array are other objects. So heres my memory layout for an initialized object: Object Property => Array (refcount = 1) Array[0] = Object (refcount=1 if created inside Object constructor) Array[1] = Object (refcount= >1 if passed into Object from userland) I have a set handler so that I can set the internal array value with an assignment. $Object = array(1, 'string'); Results in: Object Property => Array (refcount = 1) Array[0] = Object (represents an the integer 0 in this case) Array[1] = Object (represents the string "string") My question is, inside my set handler, I simply call zend_update_property, during which refcount on the old Array property gets decremented to 0 and has zval_dtor called on it. Now the objects that were inside that array are dangling. So here is the question. Do I just rely on the engine itself to destroy the dangling objects in the first array at the end of the script (which works), or do I destruct the objects myself before replacing the property (Array) with the new one? Depending on the answer, what is the process to destruct an object? Just ZVAL_DEL_REF it and let the engine GC do the rest? Thanks Bob Silva ------=_NextPart_000_0017_01C5E565.182A2540--