Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54413 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38298 invoked from network); 5 Aug 2011 23:17:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Aug 2011 23:17:08 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.42 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:33659] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 06/00-37644-2F97C3E4 for ; Fri, 05 Aug 2011 19:17:07 -0400 Received: by ywb6 with SMTP id 6so2200068ywb.29 for ; Fri, 05 Aug 2011 16:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=7AChDZi1xv5MBxJiUp5j0Gx6FLtXeIjr92A5+7AOCmw=; b=p4iiFWOWKBrsYEjWX311gDtyRKDk9BNSeDRZIRGyLwQHLgNQQ+gCLyuHgL0x6K1YfE vDwtN8fM+HcniF0wcrb590pp+4tdIjcwozfuIGZrWv1RAIEddoqMM8SaBbo2lLDxOu30 gm6W9emhn8u8fi0HNz/GQSBFDd1Ychhzt4IJA= MIME-Version: 1.0 Received: by 10.147.87.18 with SMTP id p18mr2497646yal.24.1312586222235; Fri, 05 Aug 2011 16:17:02 -0700 (PDT) Received: by 10.147.83.11 with HTTP; Fri, 5 Aug 2011 16:17:01 -0700 (PDT) In-Reply-To: <4E3C5EDE.3030401@toolpark.com> References: <4E38EC0C.9080304@lerdorf.com> <4E38FA2E.4030605@lsces.co.uk> <4E38FC67.9090200@toolpark.com> <4E39E89F.8060605@sugarcrm.com> <4E3A3643.2070305@toolpark.com> <4E3A4793.2070209@sugarcrm.com> <4E3A91E8.1020107@toolpark.com> <4E3ACA42.8000001@sugarcrm.com> <4E3BF930.9030701@toolpark.com> <4E3C5EDE.3030401@toolpark.com> Date: Sat, 6 Aug 2011 01:17:01 +0200 Message-ID: To: Lars Schultz Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] Weak References From: tyra3l@gmail.com (Ferenc Kovacs) > A parent references its childs and each child references its parent. > circular-reference nightmare...with WeakReferences I could use a > weakReference for storing the parent...so that if the parents last real > reference is discarded the childs will cleaned out as well. that is why we added the gc in 5.3, to be able to collect the circular references, which isn't used outside of their own. as Etienne pointed out on irc, it seems that some people not really familiar how php frees the unused variables. before 5.3, we only used refcounts, if a refcount is decremented to zero the zval will be freed instantly. for example calling unset, or overwriting a variable from userland decrease the refcount for that zval. but this isn't good enough, as the refcounting couldn't spot and free the zvals, which wasn't referenced from the userland anymore, only from other unused zvals, which were also referenced by another unused zval (either two zval referencing each other, or through a "circle") this is why the gc mechanism was added in 5.3. the garbage collector runs periodically, and checks the potential zvals, and finds those zval "islands" and frees those. I hope that clears up the mess, and please correct me, if I'm wrong somewhere in the explanation. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu