• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Managing EOF caching
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Managing EOF caching


  • Subject: Re: Managing EOF caching
  • From: Mike Schrag <email@hidden>
  • Date: Sun, 22 Jan 2006 00:08:21 -0500

As of 5.2, the way it works is: The snapshots in EODatabase have a reference count. Each editing context that fetches an EO increments the reference count. The EO holds onto that EO via a WeakReference. When the WeakReference is reclaimed, the snapshot reference count can decrease (note CAN, not IMMEDIATELY WILL -- the editing context keeps reference queue which is only processed periodically). When the count gets to zero, the database forgets the snapshot. If you have entity caching enabled, then EODatabase ignore reference count (or keeps it at "1" as a minimum) and it will not go away in a read-only scenario. If you modify any entity of that type and saveChanges in your EditingContext, a cached entity's cache will be entirely flushed. (NB: Keep this in mind, because if you are caching a large amount of data that is writable, it will NOT be very smart about updating that cache -- It's blown away with every update and then it immediately reloads the entire set of objects for that entity at the next access)

If you have retainsAllRegisteredObjects enabled on your editing context, it will NOT use WeakReferences. Under this circumstance, the EO reference count is only decreased when 1) you dispose the editingcontext or 2) you forget or invalidate the object.

When you modify an object in an editing context, the editingcontext keeps a strong reference to the objects until you saveChanges (or revert, reset, etc), at which point the strong references are cleared and the only remaining reference is the weakreference like before.

If you have an undo manager enabled, it will keep a strong reference to the affected EO's as long as the undo is around.

I do wonder if EC's should be using SoftReferences instead of WeakReferences ... Would seem to be more friendly to the users of those EO's.

If you are using WO pre 5.2, then none of the WeakReference stuff applies, and everything is purely done with snapshot reference counting -- it should behave like retainsAllRegisteredObjects = true in 5.2.

ms

On Jan 21, 2006, at 7:44 PM, email@hidden wrote:

Hello Art;

Thank you for this documentation reference -- very interesting.

Snapshots are reference-counted ... So as long as a reference to a snapshot from any editing context exists, the snapshot will remain. But when the last reference is broken (e.g., when an editing context is freed), the snapshot will be freed.

I see what you mean from the EODatabase javadoc in that there is definitely reference counting supported, but are you sure this is still used by the EOF machinery in WO5? The thing that makes me wonder is that EC-centric reference-counting doesn't entirely correlate to the experience I've had with EC behaviours in WO5.2. I can keep one EC instance for processes which must load up at least many hundreds of thousands of EO-s over a long period and there are generally no memory blow-outs which one might otherwise expect.


I would have *guessed* that a cunning arrangement between weak and strong EC-EO-snapshot references were being used to ensure snapshots were allowed to be destroyed appropriately using GC. I would really love to see some concrete WO5-centric tech note about the workings of "fetch timestamp lag" and "EC-based snapshot maintenace" so one could be more certain about some of these aspects of EOF.

cheers.

___
Andrew Lindesay
www.lindesay.co.nz



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mdimension.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Managing EOF caching (From: email@hidden)

  • Prev by Date: Re: Managing EOF caching
  • Next by Date: Re: Couting the objects that would be returned by a fetch specification
  • Previous by thread: Re: Managing EOF caching
  • Next by thread: Re: Managing EOF caching
  • Index(es):
    • Date
    • Thread