FAQ
Hi everyone,

I'm facing the following situation:

RecipientSet has many Recipients

A large number of Recipient objects are imported in a single
transaction. The changes are committed e.g. every 100 recipients.
Nevertheless the Recipient objects are kept in the heap, and eventually
an OutOfMemoryError occurs.

I have the feeling that the Recipient objects cannot be
garbage-collected because of the relationship references from the
RecipientSet. I didn't find any other references to the Recipient objects.

Is it possible to tell Cayenne not to keep the references, or is there
any other way to handle this issue? Do I have to create a new data
context after the changes are committed, starting with a fresh RecipientSet?

Thanks a lot in advance for any hints!

Best regards,
Andreas


--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01

Search Discussions

  • Michael Gentry at Nov 23, 2009 at 3:34 pm
    You can try dataContext.unregisterObjects() or
    dataContext.invalidateObjects() if you need to keep other things in
    your DC around. If not, throwing away the DC for a new one is a good
    approach.

    mrg
    On Mon, Nov 23, 2009 at 10:19 AM, Andreas Hartmann wrote:
    Hi everyone,

    I'm facing the following situation:

    RecipientSet has many Recipients

    A large number of Recipient objects are imported in a single transaction.
    The changes are committed e.g. every 100 recipients. Nevertheless the
    Recipient objects are kept in the heap, and eventually an OutOfMemoryError
    occurs.

    I have the feeling that the Recipient objects cannot be garbage-collected
    because of the relationship references from the RecipientSet. I didn't find
    any other references to the Recipient objects.

    Is it possible to tell Cayenne not to keep the references, or is there any
    other way to handle this issue? Do I have to create a new data context after
    the changes are committed, starting with a fresh RecipientSet?

    Thanks a lot in advance for any hints!

    Best regards,
    Andreas


    --
    Andreas Hartmann, CTO
    BeCompany GmbH
    http://www.becompany.ch
    Tel.: +41 (0) 43 818 57 01
  • Andreas Hartmann at Nov 23, 2009 at 5:12 pm
    Hi Michael,

    Michael Gentry schrieb:
    You can try dataContext.unregisterObjects() or
    dataContext.invalidateObjects() if you need to keep other things in
    your DC around. If not, throwing away the DC for a new one is a good
    approach.
    DataContext.invalidateObjects() seems to have the desired effect. I have
    to invalidate all objects, including the RecipientSet object which holds
    the references to the Recipient objects. I'll do some testing if
    everything still works as expected :)

    Thanks a lot for your reply!

    Best regards,
    Andreas

    mrg
    On Mon, Nov 23, 2009 at 10:19 AM, Andreas Hartmann wrote:
    Hi everyone,

    I'm facing the following situation:

    RecipientSet has many Recipients

    A large number of Recipient objects are imported in a single transaction.
    The changes are committed e.g. every 100 recipients. Nevertheless the
    Recipient objects are kept in the heap, and eventually an OutOfMemoryError
    occurs.

    I have the feeling that the Recipient objects cannot be garbage-collected
    because of the relationship references from the RecipientSet. I didn't find
    any other references to the Recipient objects.

    Is it possible to tell Cayenne not to keep the references, or is there any
    other way to handle this issue? Do I have to create a new data context after
    the changes are committed, starting with a fresh RecipientSet?

    Thanks a lot in advance for any hints!

    Best regards,
    Andreas


    --
    Andreas Hartmann, CTO
    BeCompany GmbH
    http://www.becompany.ch
    Tel.: +41 (0) 43 818 57 01

    --
    Andreas Hartmann, CTO
    BeCompany GmbH
    http://www.becompany.ch
    Tel.: +41 (0) 43 818 57 01
  • Juergen Saar at Nov 23, 2009 at 3:39 pm
    If they have to be in one transaction ... there is no way for garbage
    collection.

    I had the same problem some time ago and had to fight the
    OutOfMemoryException.

    The Container for the Objects and the transaction ist the DataContext. I
    splitted the Import into slices of about 10.000 Object. For every slice I
    took a new DataContext.


    Best Regards ...
    - Juergen -


    2009/11/23 Andreas Hartmann <andreas@apache.org>
    Hi everyone,

    I'm facing the following situation:

    RecipientSet has many Recipients

    A large number of Recipient objects are imported in a single transaction.
    The changes are committed e.g. every 100 recipients. Nevertheless the
    Recipient objects are kept in the heap, and eventually an OutOfMemoryError
    occurs.

    I have the feeling that the Recipient objects cannot be garbage-collected
    because of the relationship references from the RecipientSet. I didn't find
    any other references to the Recipient objects.

    Is it possible to tell Cayenne not to keep the references, or is there any
    other way to handle this issue? Do I have to create a new data context after
    the changes are committed, starting with a fresh RecipientSet?

    Thanks a lot in advance for any hints!

    Best regards,
    Andreas


    --
    Andreas Hartmann, CTO
    BeCompany GmbH
    http://www.becompany.ch
    Tel.: +41 (0) 43 818 57 01

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedNov 23, '09 at 3:20p
activeNov 23, '09 at 5:12p
posts4
users3
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase