Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53992 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92340 invoked from network); 17 Jul 2011 13:04:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2011 13:04:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=lars.schultz@toolpark.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lars.schultz@toolpark.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain toolpark.com from 195.49.42.12 cause and error) X-PHP-List-Original-Sender: lars.schultz@toolpark.com X-Host-Fingerprint: 195.49.42.12 mail1.screenlight.ch Received: from [195.49.42.12] ([195.49.42.12:54614] helo=mail1.screenlight.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/E1-02120-4DDD22E4 for ; Sun, 17 Jul 2011 09:04:21 -0400 Received: from [192.168.1.52] ([217.162.146.137]) (authenticated user lars.schultz@toolpark.com) by mail1.screenlight.ch (Kerio Connect 7.0.2 patch 1) (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for internals@lists.php.net; Sun, 17 Jul 2011 15:04:16 +0200 Message-ID: <4E22DDD0.20105@toolpark.com> Date: Sun, 17 Jul 2011 15:04:16 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.8) Gecko/20100227 Lightning/1.0b1 Thunderbird/3.0.3 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] weak references From: lars.schultz@toolpark.com (Lars Schultz) I too would welcome a solution to this problem, I've run into it several times already and always had to use a semi-satisfactory solution. I hadn't heard about weak-references before, and I generally like the concept. What I am not so sure is wether this makes everything alot more complicated for users who do not know/care about the problem or the solution. Of course the impact on those users depends on the actual solution. I came at the problem from a different angle and came to a different solution: If I could get the refcount on a certain object, and kept the object stored centrally in one list, I'd know that if the refcount is down to 1 (or some other constant) that the object ist not in use anymore. I believe that this would be quite a simple PHP addition...a simple function called: get_ref_count() or something and as I remember, that value is always stored in the zval... The only other thing that would help would be a callback (or callable) which is triggered by PHP reaching a certain memory-limit, absolute or relative. Then I could clean up memory according to my own business-logic... This way, PHP would not feature something totally new, but one could still solve the problem with some work. Do I make any sense at all? Am I missing the point? Anyway, this is an interesting problem. Cheers. Lars