Re: [VOTE] Weak References

From: Date: Fri, 05 Aug 2011 14:07:44 +0000
Subject: Re: [VOTE] Weak References
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Am 05.08.2011 14:58, schrieb John LeSueur:
Are there other advantages I'm missing? If I may, I'll respond to your questions with 3 examples.
A) Naive, straight forward approach (this will run out of memory if objects are heavy) http://pastie.org/2325252 B) Previous approach taking memory into consideration: http://pastie.org/2325317 C) Clean, memory efficient approach using SoftReferences http://pastie.org/2325254 The Problem with B) is that depending on how I use the objects, I am dropping objects from cache (to free memory) that are still in use. If I then re-add them to the cache, my singleton-pattern will be broken. NB: In the simple example I used, this is not a problem because I do not keep references to more than one object.

Thread (69 messages)

« previous php.internals (#54405) next »