Re: Understanding Weak Reference Behavior

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Apr 13 2010 - 05:09:13 EDT

  • Next message: Andrus Adamchik: "Re: Success Stories: dead link"

    On Apr 12, 2010, at 5:10 PM, Joe Baldwin wrote:

    > I have tried to ask this question previously but did not see a
    > response.

    Sorry, prolly missed your previous message.

    > Assume default cache configuration, will the following call:
    >
    >
    > ((org
    > .apache
    > .cayenne
    > .access
    > .DataContext
    > )BaseContext
    > .getThreadObjectContext()).getObjectStore().getDataRowCache().size()
    >
    > return the number of DataObjects in DataContext cache for a webapp
    > (using standard configuration)?

    No. getObjectStore().getDataRowCache() returns a shared cache object
    used by *all* DataContexts in the system (this assumes the default
    "on" value of "use shared cache" checkbox for the DataDomain is not
    changed). Also it stores "data rows", i.e. "snapshots" of objects, not
    the objects themselves.

    > (The reason I am asking is that this number this method reports
    > always grows during the life of the app, even on my dev server. I
    > would have expected this value to get smaller once all of the
    > sessions release references to the Select Query array lists, are
    > nulled, and then GC'd.)

    Actually it is an LRU, so once it reaches a certain max size, it stays
    constant. The default is 10000 snapshots and can be changed via a
    somewhat misnamed "Size of Object Cache" field for the DataDomain in
    the Modeler. Just don't set it to a value lower than an expected
    concurrent number of uncommitted objects across all contexts in the
    system.

    > What should this number look like during the course of a well
    > written webapp? Shouldn't the number go up and down depending on
    > GC? (If there is a better method for visibility, please let me know.)

    Since it is an LRU, it should grow to the cache size limit, and then
    stay constant.

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue Apr 13 2010 - 05:09:59 EDT