Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55148 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78396 invoked from network); 3 Sep 2011 11:54:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2011 11:54:11 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:33904] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/84-45280-065126E4 for ; Sat, 03 Sep 2011 07:54:09 -0400 Received: by bkas6 with SMTP id s6so2944109bka.29 for ; Sat, 03 Sep 2011 04:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=/W0Lc+VHvnertwe+f15wCxA+1SGYSvEEr3vEV0GdPx8=; b=QBUr0VgrhDPdAp8n69FNR5E08nH17wvTZgPnFCKZpAN1X7R0Bl1fx7wFRoq9p/s+6z kyg1zjr5Tm7De9YmHjghryLVJNvonZBUQVtEwd38Blv6qwhi+6JSSEh2OUuEXB3OnYaM 1vWB8/rwUJxV8+tQLI1TNWsDt104uGUuSRGiY= MIME-Version: 1.0 Received: by 10.204.153.6 with SMTP id i6mr1125968bkw.90.1315050844723; Sat, 03 Sep 2011 04:54:04 -0700 (PDT) Sender: ekneuss@gmail.com Received: by 10.204.40.199 with HTTP; Sat, 3 Sep 2011 04:54:04 -0700 (PDT) In-Reply-To: References: <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> <4E3D073A.9050709@toolpark.com> Date: Sat, 3 Sep 2011 13:54:04 +0200 X-Google-Sender-Auth: YRMEK8VmGPu9vVy7gn7LJ7Lee54 Message-ID: To: Arvids Godjuks Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0015175cd5f2761b5404ac082275 Subject: Re: [PHP-DEV] [VOTE] Weak References From: colder@php.net (Etienne Kneuss) --0015175cd5f2761b5404ac082275 Content-Type: text/plain; charset=UTF-8 Hi, On Tue, Aug 9, 2011 at 14:22, Arvids Godjuks wrote: > I have mixed feelings about this proposal - from one point it's quite > neat - ability to mark circular references for the memory manager so > it can free them sounds very delicious, especially for some cases. I > had run into my own bunch of problems with memory in PHP in the past > and right now I'm running a daemon written in PHP in production on > 5.3.6. Careful construction and knowledge that circular references > actually do harm I did add safeguards that actually clean up the > objects in recursive manner (and objects have internal flags that > cleanup has been initiated - that way I make sure I cleanup the same > object only once). That sort of planing at the design stage makes it > far more friendly with memory, so it doesn't mean that PHP should have > soft references. > > My opinion is that if this can be done without using significant > resources and will not have major issues while implementing - it can > be added, otherwise just skip it - better off fixing bugs and > optimizing :) > Weak references have been implemented in a PECL extension since weeks now: http://php.net/weakref and/or http://pecl.php.net/weakref It feels like you're beating up a dead horse here. A discussion for bundling it might occur in the future, but given the feedbacks PECL might very well be the right place for it. Best, > > 2011/8/6 Lars Schultz : > > Am 06.08.2011 02:14, schrieb Hannes Landeholm: > >> > >> Yeah I think there's a lot of misunderstandings going on with weak/soft > >> references and how the garbage collector works. Weak/soft references is > >> not > >> some kind of solution to the cyclic reference problem. The GC takes care > >> of > >> that already. You can use whatever OOP patterns with whatever reference > >> graphs you like Lars, the GC will free the entire structure as soon as > the > >> cyclic collector runs after you are not referencing it anymore. You > might > >> have become a bit confused with my last post where I explained how one > >> could > >> theoretically hack together a soft reference implementation by using > weak > >> references and some properties of cyclic collection. Also property > access > >> performance is off-topic. > > > > I did not misunderstand how weak/soft-references or php's new GC works. > > > > Having a GC collect circular references is neat, but if I remember > > correctly, collecting them (which is why there are other, faster methods > but > > which require more memory) is neither simple nor fast (whatever that > means) > > so...if I can assist the GC by clearly stating that my child-objects may > be > > collected as soon as they and their parent are not referenced from > userland > > anymore thus not requiring the GC and thus freeing memory as soon as > > possible,...seems like an optimization worth thinking of. Especially if I > > tend to have vast structures with hundreds of objects. > > > > In 5.2 (we can't move our project to 5.3 yet because of a BC issue) i had > to > > manually clear those cycles before dropping the last userland reference > to > > the tree of objects because otherwise I'd run into memory problems when > > processing alot of those trees. > > > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch --0015175cd5f2761b5404ac082275--