Re: ResultIterator and OutOfMemory

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Aug 19 2005 - 09:31:59 EDT

  • Next message: Andrus Adamchik: "Re: ResultIterator and OutOfMemory"

    First thing of course is to check that enough memory is available to
    the JVM. Increase it using -Xmx command line switch, and this maybe
    the end of it. If this doesn't help, try other things below.

    > For checking the order I have definded a second DataContext
    > that does some inserts into a separate table.
    > This context allways gets a commit/rollback after
    > having processed one order ...

    That might be a problem if a second DataContext accumulates too many
    objects. THEY ARE NOT REMOVED FROM CACHE ON COMMIT. I'd suggest to
    get rid of a second DataContext after every X number of commits and
    replace it with a new instance. Or use
    ObjectStore.startTrackingNewObjects()/unregisterNewObjects() API to
    manually clean a DataContext without disposing it.

    > Any hint, how to find the memory eating instance without the help
    > of a profiler?

    You can get a rough estimate of the number of objects registered with
    each DataContext.

    In Cayenne 1.1 you would do this:

    // comment out this code in production as "getObjects" clones objects
    array on every call
    context.getObjectStore().getObjects().size();

    In Cayenne 1.2 there is a more efficient way:

    context.getObjectStore().registeredObjectsCount();

    Andrus

    On Aug 19, 2005, at 5:16 PM, jsaa..eb.de wrote:

    >
    > Hi,
    >
    > I'v got a problem with the ResultIterator.
    > For my understanding, this is the way to iterate thru
    > large amount of datarows.
    >
    > I have to analyze all orders in database
    > So I took the example from:
    > http://www.objectstyle.org/cayenne/userguide/perform/result-
    > iterator.html
    > and did it this way ...
    >
    > But after about 46000 rows an OutOfMemoryException ist raised
    >
    > For checking the order I have definded a second DataContext
    > that does some inserts into a separate table.
    > This context allways gets a commit/rollback after
    > having processed one order ...
    >
    > Any hint, how to find the memory eating instance without the help
    > of a profiler?
    >
    > Thanx
    > --- Juergen ---
    >
    >
    >
    > ______________________________________________________________________
    > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
    > Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Aug 19 2005 - 09:32:00 EDT