İlgi:Re:OutOFMemory Java heap exeception

From: emre.yilma..r.net
Date: Fri Dec 23 2005 - 06:24:17 EST

  • Next message: Claudio Rosati: "R: cache synchronization"

    Hi,

    - To throw away committed objects from the ObjectStore.
     I use the below code for your above advice but I get the same error.
    context.getObjectStore().getDataRowCache().clear();
    context.unregisterObjects(context.newObjects());
    context.unregisterObjects(context.deletedObjects());
    context.unregisterObjects(context.modifiedObjects());
    System.gc();
      
    - To use multiple DataContext and dispose them when no needed.
     For this metod how can I dispose the multiple DataContext?
    You mean DataContext to be restoring. If you mean this I use below codes for
    this but the result is unchange.

    context = null;
    System.gc();
    FileConfiguration conf = new FileConfiguration("cayenne.xml");
    conf.addFilesystemPath(new File("resources/cayenneolddb"));
    Configuration.initializeSharedConfiguration(conf);
    context = DataContext.createDataContext();
    context.commitChanges();
                    

    >
    > Kimden: Oscar Maire-Richard <omair..idsa.es>
    > Tarih: 2005/12/23 Fri AM 11:11:42 GMT+02:00
    > Kime: cayenne-use..bjectstyle.org
    > Konu: Re: OutOFMemory Java heap exeception
    >
    > Hi,
    > I am also having problems with the heap memory. A first thing to do is
    > to start the java virtual machine with a bigger heap size than the
    > default. I use -Xms256m -Xmx256m. This helps with garbage collection or
    > if you manage very big sized objects, but I think that your problem is
    > that you have a lot of alive objects in memory.
    > I reported yesterday a similar problem (look for subject "heap memory
    > not released") and people propose to me to try a couple of workarounds:
    > - To use multiple DataContext and dispose them when no needed.
    > - To throw away committed objects from the ObjectStore.
    >
    > Oscar Maire-Richard
    >
    > emre.yilma..r.net wrote:
    >
    > >Hi,
    > >
    > >I want to transfer database records from one db to another.
    > >Transfer size nearly 5000 data and this each data has nearly 1000 relational
    > >objects.
    > >---->I firstly try the Paged query like :
    > >
    > >public static List getPersonels(){
    > >SelectQuery query = new SelectQuery(Personel.class);
    > >query.setPageSize(10);
    > >return context.performQuery(query);
    > >}
    > >this method run of the first nearly 900 count of personel class but personel
    > >object has 2000 rows.
    > >
    > >------>Then I try the ResultIterator like :
    > >
    > >public SelectQuery getPersonels(){
    > >SelectQuery query = new SelectQuery(Personel.class);
    > >query.setFetchingDataRows(true);
    > >query.setPageSize(10);
    > >return query;
    > >}
    > >
    > >used below class
    > >public static void transferPersonels(){
    > >SelectQuery oldDbItems = tr.com.htr.hgys.olddb.Personel.getPersonels();
    > >ResultIterator it = null;
    > >try {
    > >it = tr.com.htr.hgys.olddb.Personel.context.performIteratedQuery(oldDbItems);
    > >while(it.hasNextRow()) {
    > >Map row = it.nextDataRow();
    > >tr.com.htr.hgys.olddb.Personel oldDbItem = (tr.com.htr.hgys.olddb.Personel)
    > >tr.com.htr.hgys.olddb.Personel.context.objectFromDataRow(
    > >tr.com.htr.hgys.olddb.Personel.class,(DataRow)row,true);
    > >tr.com.htr.hgys.newdb.CopyOfPersonel newDbItem = (tr.com.htr.hgys.newdb.
    > >CopyOfPersonel) context.createAndRegisterNewObject("Personel");
    > >try{
    > >PersonelIdentity newIdent = PersonelIdentity.transferPersonelIdentity
    > >(oldDbItem);
    > >Card card = Card.transferPersonelCard(oldDbItem);
    > >tr.com.htr.hgys.olddb.Daire daire = tr.com.htr.hgys.olddb.Daire.getDaire
    > >(oldDbItem.getDaireId());
    > >String deptName = null;
    > >if(daire != null)
    > >deptName = daire.getDaireName();
    > >Department dept = Department.getDepartment(deptName);
    > >tr.com.htr.hgys.olddb.Gorev görev = tr.com.htr.hgys.olddb.Gorev.getGorev
    > >(oldDbItem.getGorevId());
    > >String jobName = null;
    > >if(görev != null)
    > >jobName = görev.getGorevName();
    > >Job job = Job.getJob(jobName);
    > >tr.com.htr.hgys.olddb.Bolum bolum = tr.com.htr.hgys.olddb.Bolum.getBolum
    > >(oldDbItem.getBolumId());
    > >String sectionName = null;
    > >if(bolum != null)
    > >sectionName = bolum.getBolumName();
    > >Section section = Section.getSection(sectionName);
    > >tr.com.htr.hgys.olddb.Unvan unvan = tr.com.htr.hgys.olddb.Unvan.getUnvan
    > >(oldDbItem.getUnvanId());
    > >String titleName = null;
    > >if(unvan !=null)
    > >titleName = unvan.getUnvanName();
    > >Title title = Title.getTitle(titleName);
    > >tr.com.htr.hgys.olddb.Groups group = tr.com.htr.hgys.olddb.Groups.getGroups
    > >(oldDbItem.getGroupId());
    > >String groupName = null;
    > >if(group != null)
    > >groupName = group.getGroupName();
    > >Vehicle vehicle = Vehicle.getVehicle(oldDbItem);
    > >newDbItem.setAccessGroupName(groupName);
    > >newDbItem.setAddress(oldDbItem.getAdres());
    > >newDbItem.setAutoCardRel(null);
    > >newDbItem.setCardRel(card);
    > >newDbItem.setClassRel(null);
    > >newDbItem.setDeleted(new Boolean(false));
    > >newDbItem.setDepartmentRel(dept);
    > >newDbItem.setHomePhone(oldDbItem.getTelEv());
    > >newDbItem.setJobRel(job);
    > >newDbItem.setTaxNo(oldDbItem.getVergino());
    > >newDbItem.setPersonelIdentityRel(newIdent);
    > >newDbItem.setPersonelImageRel(null);
    > >newDbItem.setPersonList(null);
    > >newDbItem.setRecordDate(oldDbItem.getDateofrec());
    > >newDbItem.setRecordNo(oldDbItem.getSicilno());
    > >newDbItem.setRoomNumber(oldDbItem.getOda());
    > >newDbItem.setSectionRel(section);
    > >newDbItem.setTitleRel(title);
    > >newDbItem.setUnitRel(null);
    > >newDbItem.setVehicleRel(vehicle);
    > >newDbItem.setWirelessPhone(oldDbItem.getTelCep());
    > >newDbItem.setWorkPhone(oldDbItem.getTelDahili());
    > >context.commitChanges();
    > >
    > >}catch (Exception e){
    > >e.printStackTrace();
    > >}
    > >java.lang.System.gc();
    > >}
    > >}
    > >catch(CayenneException ex) {
    > >ex.printStackTrace();
    > >}
    > >finally {
    > >try {
    > >it.close();
    > >}catch(CayenneException closeEx) {
    > >closeEx.printStackTrace();
    > >}
    > >}
    > >context.commitChanges();
    > >}
    > >
    > >this time I get an error of cayenne for connection timeout.
    > >I guess this is caused by other querys in transferPersonels() metod.
    > >
    > >How can I solve the out of memory problem..
    > >
    > >Thanks for help...
    > >
    > >
    > >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Dec 23 2005 - 06:23:58 EST