Peak memory usage for Cayenne

From: Øyvind Harboe (oyvind.harbo..ylin.com)
Date: Fri Jun 20 2008 - 03:45:50 EDT

  • Next message: Øyvind Harboe: "Re: Peak memory usage for Cayenne"

    I'm running into out of memory problems processing a large number of
    elements from a query and I'm lacking a good understanding of how
    to make sure that Cayenne can garbage collect it's objects.

    Perhaps there are some do's and don'ts, but I don't know what they are at this
    point.

    For my purposes it doesn't matter how much memory Cayenne uses to
    handle a small number of objects, but it becomes a problem if
    the memory consumption is proportional to the # of objects returned
    from a query.

    I'm running Cayenne 3.x

    1. Consider the code below. Will all the objects from the query
    be locked in memory?

    query=new SelectQuery(Foo.class);
    query.setPageSize(1000); /* does this matter? */
    /* Does performQuery return a clever implementation of
    a List that does not lock the CayenneDataObjects into memory?
    */
    l=context.performQuery(query);
    while (i.hasNext())
    {
            Foo f=(Foo) i.next();

           .... do some processing here that ...

    }

    2. When does peak memory usage occur above?

    3. Can a CayenneDataObject be garbage collected as long as it's
    DataContext is in scope?

    I'm wondering because as far as I have understood the two if
    statements below are equivalent when a & b are CayenneDataObjects
    in the same DataContext.

    That is if 'a' can be garbage collected during the lifetime of the
    DataContext, then 'a' is points to different objects during the
    lifetime of CayenneDataObject's and a==b just 'barely' works.
    If any information is stored in 'a' then it can be garbage collected
    during the lifetime of the CayenneDataContext.

    if (a==b)

    if (a.getObjectId().equals(b.getObjectId()))

    4. Should I consider some "clever" implementation of a query that
    ensures that only a small amount of CayenneDataObject's are
    locked in memory at the time?

    Some ideas:

    - use performIteratedQuery() w/setPageSize()
    - ResultIterator.nextDataRow() is a bit strange: it returns a Map<>, but
    perhaps I can safely upcast that.
    - use objectFromdataRow()

    -- 
    Øyvind Harboe
    http://www.zylin.com/zy1000.html
    ARM7 ARM9 XScale Cortex
    JTAG debugger and flash programmer
    



    This archive was generated by hypermail 2.0.0 : Fri Jun 20 2008 - 03:46:28 EDT