Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27591 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15124 invoked by uid 1010); 22 Jan 2007 20:12:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15109 invoked from network); 22 Jan 2007 20:12:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2007 20:12:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=schultz@widescreen.ch; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=schultz@widescreen.ch; sender-id=unknown Received-SPF: error (pb1.pair.com: domain widescreen.ch from 62.2.95.247 cause and error) X-PHP-List-Original-Sender: schultz@widescreen.ch X-Host-Fingerprint: 62.2.95.247 mxout.hispeed.ch Linux 2.4/2.6 Received: from [62.2.95.247] ([62.2.95.247:56438] helo=smtp.hispeed.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/86-07357-AAA15B54 for ; Mon, 22 Jan 2007 15:12:27 -0500 Received: from [127.0.0.1] (84-72-85-223.dclient.hispeed.ch [84.72.85.223]) (authenticated bits=0) by smtp.hispeed.ch (8.12.11.20060308/8.12.11/taifun-1.0) with ESMTP id l0MKCMtY026671; Mon, 22 Jan 2007 21:12:23 +0100 Message-ID: <45B51AA8.8090307@widescreen.ch> Date: Mon, 22 Jan 2007 21:12:24 +0100 User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stanislav Malyshev , internals@lists.php.net References: <45B0E1EE.2030102@widescreen.ch> <45B123F5.3070803@zend.com> <45B3929B.8040803@widescreen.ch> <45B51124.90207@zend.com> In-Reply-To: <45B51124.90207@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 0704-3, 22.01.2007), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: ClamAV version 0.88.7, clamav-milter version 0.88.7 on smtp-01.tornado.cablecom.ch X-Virus-Status: Clean X-DCC-spamcheck-01.tornado.cablecom.ch-Metrics: smtp-01.tornado.cablecom.ch 1377; Body=2 Fuz1=2 Fuz2=2 Subject: Re: [PHP-DEV] PHP Object-Caching and Reference Counting From: schultz@widescreen.ch (Lars Schultz) > That's correct. However, it is not guaranteed that your unset would > delete last reference - there can be references on stack, in temp > variables in current expressions being calculated (function call could > happen in mid-expression), etc. Of course, it might be that your code > is very controlled so you know it never happens, but as general case > you can't rely on it. Ok. I got your point. You are right that it's hard to predict where references could be found. > Also, if you check only zval refcount, you might unset objects that > actually are referenced from other places but by different zvals, > since one object could be referenced by a number of zvals. I am not familiar with the term: "zval"...My understanding of php comes from extensive usage...Can you give me a specific example? $foo = new MyObject(); //ref count to Object #1 is 1 $bar = $foo; //ref count to Object #1 is 2 if ( ($zapp = $bar)->doIt() ) {...} //ref count is 3 or 4? but it doesn't matter really... I also believe that my reasons for this feature only require that there are not any less references than are returned by ref_count()...I am aware that the usage is for quite an advanced concept...but why shouldn't PHP also be used for this. The one argument against this feature that carries the most weight, for me, is that PHP might change the behaviour of its memory management and then keeping count of references would be an unecessary overhead, which might lead to my code not working anymore if the feature were to be dropped. Are there likely to be any changes in the future?...and is there an other solution to this concept? I find it rather neat...;) Especially if you couple it with the magic function __wake() where the objects re-register themselves in the cache-list... id] = $this; } ... } ?> In this case all objects not referenced by any variable in the $_SESSION array (or it's descendants), would be destructed at the end of the script. This way the objects remain unique even across sessions and some kind of cleaning up is done by the serialization process. The trouble is that this only works at the end of the script where of course even the current stack is not used anymore. So I can't use this principle in a function-call. Or does anyone of you have a different solution?;)