Hibernate version: Last one
Code between sessionFactory.openSession() and session.close():
Code:
public static Object createSession() throws Exception {
Session session = (Session) currentSession.get();
Owner id = null;
System.out.println(session);
if (session == null) {
System.out.println("No Session Found - Create and give the identity");
session = getSessionFactory().openSession();
currentSession.set(session);
id = trueOwner;
} else {
System.out.println("Session Found - Give a Fake identity");
id = fakeOwner;
}
sessions.add(session);
return id;
}
Code:
public static void closeSession(Object ownership) throws Exception {
if (((Owner) ownership).identity) {
System.out.println("Identity is accepted. Now closing the session");
Session session = (Session) currentSession.get();
session.flush();
session.clear();
session.close();
currentSession.set(null);
} else {
System.out.println("Identity is rejected. Ignoring the request");
}
}
Full stack trace of any exception that occurs:OutOfMemory
Name and version of the database you are using:Oracle 9
OK, after fighting against an OutOfMemory exception all the weekend, I come to you, experts to help me with my case, I have tried a lot of things but no success, after using JProbe I could do the follow test:
1. Stress test for 10 minutes (Using SOAPUI, yes, I'm developing a WebService)
2. I invoke a Garbage Collector and take a snapshot of current loaded classes
The result, sorting by memory usage is:
Code:
Package Class Count Memory
char [ ] 68,278 (13.6%) 22,685,896 (66.2%)
java.lang String [ ] 157,285 (31.3%) 2,663,576 (7.8%)
java.lang String 69,132 (13.7%) 1,659,168 (4.8%)
org.hibernate.loader.entity EntityLoader 9,750 (1.9%) 858,000 (2.5%)
java.util HashMap$Entry 32,316 (6.4%) 775,584 (2.3%)
java.util HashMap$Entry [ ] 7,535 (1.5%) 718,128 (2.1%)
java.lang String [ ] [ ] 12,240 (2.4%) 635,760 (1.9%)
java.lang.reflect Method 6,798 (1.4%) 543,840 (1.6%)
org.hibernate.loader DefaultEntityAliases 10,200 (2.0%) 408,000 (1.2%)
java.util HashMap 7,535 (1.5%) 301,400 (0.9%)
int [ ] 6,778 (1.3%) 183,112 (0.5%)
boolean [ ] 9,210 (1.8%) 177,000 (0.5%)
org.hibernate.persister.entity Loadable [ ] 10,200 (2.0%) 163,200 (0.5%)
OK, I believe that the first classes are being used by the next one, in this case I could check that EntityLoader Class is not being collected by GC.
Could someone help me to ensure that all my hibernate objects are being closed, so, I believe that I could fix this OutOfMemory error.
Thanks in advance.