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.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php