Hello Andi,
The problem is that script can fetch very large number of objects and all of them doesn't fit in the memory. Lets say we have very large list of objects (several millions objects or more). And our script traverse the list and fetch objects one by one and do some calculations (for example calculates total sum). So at each moment of time only one persistent object is actually needed. But without weak references we will have to keep all these millions of objects in memory.
If you need to go over a list of million objects you are doing something wrong :)
Also performance of OODBBS greatly depends on efficient caching of objects. If we throw away all objects after each request and has to reload them from the server for each request, then performance will we awful. It is very significant to be able to cache most frequently used objects. LRU or some other discipline can be used for it. But any not depending from the discipline we use we need some mechanism which allows to map OPIDs to instances and do not prevent GC from collecting the objects.
I disagree. JDO performs well and doesn't cache the objects as usually pessimistic locking is used with it. Of course, if you want to use optimistic locking and the nature of your application allows you to do so efficiently the caching might make sense (or it's mainly a read-only app).
That is why almost all languages with implicit memory deallocation have some kind of weak references. And I was wondered when do not find such facility in PHP.
Using __destruct method (thanks to George) it may be possible to implement what I need, but only if object cache is implemented in C (and so is not visible for PHP garbage collector). So no pure PHP solution exits. Unfortunately I didn't fins any reference to __destruct method in PHP manual and do not understand how it works. If I just declare __destruct method in class, it is not invoked when object is destructed.
I don't quite understand why you need __destruct() as other systems in Java don't use this but I might be completely misunderstanding what you want to do.
Yes, you'll need to do this with a C extension.
Anyway, good luck. I hope the Engine 2 solves some of your problems (such as object handles which allow you to always access the same DB object).
Andi
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php