On Wed Aug 3 05:16 PM, Lester Caine wrote:
> Jan Dolecek wrote:
> > I was waiting for this for a while! I wrote a blog post how to get 
> > best benefits from weak references:
> > http://blog.juzna.cz/2011/08/weak-references-in-php/
> > Perhaps this will help showing people what are they good for.
> 

Or you can use various caching algorithms (LRU, MRU, ..) to reduce memory usage:

$this->cache = new ArrayLimit(2);
$this->cache->add(new LargeObject('A'));
$this->cache->add(new LargeObject('B'));
$this->cache->add(new LargeObject('C'));
$this->cache->count(); // 2

To solve a "caching problem" weak references aren't very helpful since there's 
no way to know when or which objects will be garbage collected 
(non-deterministic).



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to