On 19/01/10 3:34 AM, Andrus Adamchik wrote:
> http://cayenne.apache.org/doc/objectcontext-memory-management.html
>
> Wonder if we should go from WEAK to SOFT as a default policy for object
> retention in the ObjectStore. I just got a few annoying cases of objects
> being immediately gc'd after each request, so a new request looking them
> up by id finds them in the shared cache instead of local (somewhat slow)
> and then previously resolved to-many relationships are re-read anew
> (very slow).
>
> Of course locally I just switched my ObjectContext factory service to
> use SOFT, so I am all set (I am yet to see it in production; wonder how
> that affects already slow major GC cycles). But I am wondering if that
> would make a better default policy for 3.1?
It would appear that soft is a better policy, as long as users are expecting that their JVM will continue to grow until it uses up all its memory. It may lead users to think at first that Cayenne has some sort of memory leak.
I found this interesting article discussing how the gc works with soft references:
http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html
Because we could be generating objects very quickly (a big select on the database), how the gc does its magic is going to be very important. How will it keep up with the memory pressure of creating new objects at a high rate?
The comments on that page are interesting too: that the soft references are not thread safe. Does that affect us?
And the Google commons code is also interesting, with http://google-collections.googlecode.com/svn/trunk/src/com/google/common/base/FinalizableReferenceQueue.java
Ari
-- --------------------------> Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
This archive was generated by hypermail 2.0.0 : Wed Jan 20 2010 - 07:16:16 EST