Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54411 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28609 invoked from network); 5 Aug 2011 21:10:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Aug 2011 21:10:09 -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:50920] helo=mail1.screenlight.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/42-10106-D2C5C3E4 for ; Fri, 05 Aug 2011 17:10:08 -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; Fri, 5 Aug 2011 23:10:01 +0200 Message-ID: <4E3C5C27.6020401@toolpark.com> Date: Fri, 05 Aug 2011 23:09:59 +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: <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> <4E3C2C8F.7050700@officechristmas.co.uk> In-Reply-To: <4E3C2C8F.7050700@officechristmas.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [VOTE] Weak References From: lars.schultz@toolpark.com (Lars Schultz) Am 05.08.2011 19:46, schrieb Jezz Goodwin: > As Chris Stockton points out http://news.php.net/php.internals/54391 > there is always going to be additional code that has to check to see if > the reference is still valid. But don't you see that in exchange for one little IF you get so much more...what's an NPE compared to an OOME;) > If the only concern here is running out of memory, surely you could > design a framework that could reduce it's memory usage without having to > get rid of it's objects. It's not about a framework, it's about making use of what is available (memory & processing power) and balancing those two....and PHP is not very efficient with its objects...I might be wrong here, but I think that because PHP supports dynamic assigning of properties, it addresses them by name and not as in a c++ object by memory-offset, but I am out of my depth here, having deduced this without looking at the source-code. > For example, your ORM objects will have a store of data. You could run a > process every now and again that deletes the data from the objects > (everything except the ID of the table). And then write it in to the > framework so that if you start using the object again it goes and gets > it's data back? Actually my use-case is single-threaded and linear, so I can't really run a second process...but if this is your solution compared to SoftReferences with one IF, then I am not sure I like yours better. Also WeakReferences and SoftReferences are used in completely different situations. The two concepts are related but not its applications. I just remembered something I encountered in an AS3 project I made...it's a perfect example for WeakReferences. (you might not like AS3 but you may appreciate the fact that it also uses this concept) ================ http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/EventDispatcher.html#addEventListener%28%29 public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void If you no longer need an event listener, remove it by calling removeEventListener(), or memory problems could result. Event listeners are not automatically removed from memory because the garbage collector does not remove the listener as long as the dispatching object exists (unless the useWeakReference parameter is set to true). ================