These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: heap size problem
PostPosted: Fri Aug 24, 2007 12:57 pm 
Beginner
Beginner

Joined: Fri Jun 15, 2007 6:32 am
Posts: 23
hi ,
i have a db xml , each folder holds approx 12K files each file holds around 50 entities (each item is an appearance of a class) that translates to approx 0.5m insert rows per folder and i'm getting java heap size errors one some of the folders , i've trimmed my code everywhere and quite frankly it's a very simple code using jdom .
Code:
try{
         
         if ((session!=null)&&(session.isOpen()))session.close();
         session = openSession();
         transaction = session.beginTransaction();
         transaction.begin();
         File file = new File(path);
         if (file.isDirectory()) {
            files = file.listFiles();
            for (i = 0; i < files.length; i++) {
                 saveToEntity(files[i] + "");
               
            }
         }
         transaction.commit();
         session.close();
         HibernateUtil.closeResources(session, transaction);
      }
      catch (Exception e) {
         System.out.println(files[i]);
         e.printStackTrace();
      }

savetoentity does a session.save(stock) per each entity
how can this be solved ?
savetoentity should realy be called savetoentities (each file holds many entitties)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 26, 2007 2:07 pm 
Beginner
Beginner

Joined: Fri Jun 15, 2007 6:32 am
Posts: 23
people i can realy use some help here , it seems hibernate is refusing to clear the cache even tough i've commited the transaction .
is that a known bug or am i doing something wrong ?
when i session.clear it helps but still that's no way to work .


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 26, 2007 3:11 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:44 pm
Posts: 33
kernel77 wrote:
people i can realy use some help here , it seems hibernate is refusing to clear the cache even tough i've commited the transaction .
is that a known bug or am i doing something wrong ?
when i session.clear it helps but still that's no way to work .


You might try something like the following which I picked up in Java Persistence with Hibernate:

Code:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
for ( int i=0; i<100000; i++ ) {
    Item item = new Item(...);
    session.save(item);
    if ( i % 100 == 0 ) {
        session.flush();
        session.clear();
    }
}
tx.commit();
session.close();



-Kaj :)


[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.