On 14 July 2011 20:42, Ferenc Kovacs <tyr...@gmail.com> wrote: > To spare the "5.4 features vote" thread from the off-topic discussion, > we can continue here. > Hannes Landeholm brought this idea up, see > http://news.php.net/php.internals/53956 and > http://news.php.net/php.internals/53959 > I would suggest that Hannes create an rfc, and add some examples and > introduce the weak references in general and how this can be useful, > what problems do they solve (it was discussed in the bugreport, but it > wasn't clear as far as I can tell from the comments).
Not being an expert here, so the questions may have obvious answers. How often does the gc cycle run during a script? Can preemptive cleanup actually cause more of a headache? In reading about weak references on http://en.wikipedia.org/wiki/Weak_reference, weak references look like a perfect use case for memory limited caches, but I wonder if there would be a way of synching a TTL to the weak referenced objects, so that they essentially automatically expire (or can be expired and expunged). A system controlled TTL for weak referenced objects. So, void SplWeakRef::__construct(object $ref, [int $ttl = -1]) $ttl = -1 would allow the object to be gc'd in the normal way, but any other value would be a hint to how long the object would be expected to last for. If gc happens frequently, then $ttl acts as a limiter and I think this could be very useful. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php