Re: ObjectStore OutOfMemory Exception

From: Michael Gentry (mgentr..asslight.net)
Date: Thu Nov 19 2009 - 09:45:04 EST

  • Next message: Joe Baldwin: "DataContext.deleteObjects()"

    Do you need your objects to live in "context" for an extended period?
    Could you do this instead?

    public void AddPacket(Integer serviceType, Date startTime, Date arrivalTime){
        DataContext context = DataContext.createDataContext();
        Packet p = (Packet) context.newObject(Packet.class);
        ...
    }

    That will allow the context to be garbage collected (if that will work
    with your code).

    mrg

    On Thu, Nov 19, 2009 at 9:33 AM, Mattex83 <matteo.parod..bodata.com> wrote:
    >
    > Hi,
    >
    > I've a memory trouble using the last version of Cayenne ( v3.0b). I created
    > a table to store data coming with a frequency of 10-20 record per second.
    > After few hours my application run out of memory.
    >
    > Heap report says that there are about 15000 records (and 15000 ObjectId)
    > referenced by my application.
    >
    > This app hasn't any hashmap or list of records (it just creates persistent
    > objects) so I think that these records are stored in ObjectStore.
    >
    > On commit I print these info:
    >
    > log.info("Registered Count:
    > "+context.getObjectStore().registeredObjectsCount());
    > log.info("New Count: "+ context.newObjects().size());
    > log.info("Delete Count: "+ context.deletedObjects().size());
    > log.info("Modify Count: "+ context.modifiedObjects().size());
    > log.info("Cache Size: "+context.getQueryCache().size());
    >
    > the first one raise on each commit other logs are 0.
    > So I think that context keeps committed objects, but I understood that v3.0
    > shouldn't do this...
    >
    > How can I avoid this? or How can I clear the context registered Objects?
    >
    > my add function is:
    >
    > public void AddPacket(Integer serviceType, Date startTime, Date
    > arrivalTime){
    >
    >                Packet p = (Packet) context.newObject(Packet.class);
    >
    >                p.setServiceType(serviceType);
    >                p.setStartTime(startTime);
    >                p.setArrivalTime(arrivalTime);
    >
    >                try{
    >                        context.commitChanges();
    >                }
    >                catch(ValidationException e){
    >                        log.warn("Validation failed. Packet discarded\n");
    >                        try{
    >                                context.rollbackChanges();
    >                        }
    >                        catch(Exception e1){
    >                                e1.printStackTrace();
    >                        }
    >                }
    >                catch(Exception e){
    >                        e.printStackTrace();
    >                        try{
    >                                context.rollbackChanges();
    >                        }
    >                        catch(Exception e1){
    >                                e1.printStackTrace();
    >                        }
    >
    >                }
    >                log.info("Registered Count:
    > "+context.getObjectStore().registeredObjectsCount());
    >                log.info("New Count: "+ context.newObjects().size());
    >                log.info("Delete Count: "+ context.deletedObjects().size());
    >                log.info("Modify Count: "+ context.modifiedObjects().size());
    >                log.info("Cache Size: "+context.getQueryCache().size());
    >                context.getObjectStore().getDataRowCache().clear();
    >                context.getQueryCache().clear();
    > }
    >
    >
    > Thanks in advance
    >
    >
    > Matteo
    > --
    > View this message in context: http://n3.nabble.com/ObjectStore-OutOfMemory-Exception-tp36832p36832.html
    > Sent from the Cayenne - User mailing list archive at Nabble.com.
    >



    This archive was generated by hypermail 2.0.0 : Thu Nov 19 2009 - 09:46:09 EST