hello, everybody
I ran into serious memory issues with Hibernate. All I do is simply try to instantiate a SessionFactory, nothing more. The schema is mildly complex (681 tables of 10 to 40 columns), using one-to-many and many-to-one wherever this is possible, lazy loading wherever this is possible.
Using Hibernate 2.0.3, the results are the following :
- time to instantiate a SessionFactory = between 30 and 35 seconds
- used memory as reported by runtime = apx. 25MB
Using Hibernate 2.1.1beta6 (doesn't compile yet with 2.1.1final and I really don't want to mess with it until I find the root of the problem):
- after apx 60 seconds configuration.buildSessionFactory() gives up with an OutOfMemory report, usually something in the lines of :
Code:
GRAVE: CGLIB Enhancement failed
net.sf.cglib.CodeGenerationException
at net.sf.cglib.CodeGenerator.define(CodeGenerator.java:179)
at net.sf.cglib.Enhancer.enhanceClassHelper(Enhancer.java:239)
at net.sf.cglib.Enhancer.enhanceHelper(Enhancer.java:221)
at net.sf.cglib.Enhancer.enhance(Enhancer.java:149)
at net.sf.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:52)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:747)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:749)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:718)
at fr.infologic.testhibby.HibernateInitializer.createSessionFactory(HibernateInitializer.java:98)
at fr.infologic.testhibby.HibernateInitializer.getSessionFactory(HibernateInitializer.java:40)
at fr.infologic.testhibby.TestHibby.performBenchmark(TestHibby.java:37)
at fr.infologic.testhibby.TestHibby.main(TestHibby.java:22)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sf.cglib.CodeGenerator.defineClass(CodeGenerator.java:205)
at net.sf.cglib.CodeGenerator.define(CodeGenerator.java:175)
... 13 more
Caused by: java.lang.OutOfMemoryError
Exception in thread "main"
OutOfMemory happens even with absurd settings such as "-Xms1500M -Xmx1500M -Xss32M". I have tried tens of combinations of memory sizes and still unable to pass the sessionfactory instantiation phase...
My hibernate.properties:
Code:
hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
hibernate.query.imports net.sf.hibernate.test, net.sf.hibernate.eg
hibernate.dialect net.sf.hibernate.dialect.SAPDBDialect
hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB
hibernate.connection.username TEST
hibernate.connection.password *********
hibernate.connection.url jdbc:sapdb://localhost/TST?cache=s&timeout=0
hibernate.connection.pool_size 10
hibernate.statement_cache.size 10
hibernate.dbcp.maxActive 100
hibernate.dbcp.whenExhaustedAction 1
hibernate.dbcp.maxWait 120000
hibernate.dbcp.maxIdle 10
hibernate.dbcp.testOnBorrow true
hibernate.dbcp.ps.maxActive 100
hibernate.dbcp.ps.whenExhaustedAction 1
hibernate.dbcp.ps.maxWait 120000
hibernate.dbcp.ps.maxIdle 100
hibernate.dbcp.validationQuery select 1 from dual
hibernate.connection.provider_class net.sf.hibernate.connection.DBCPConnectionProvider
hibernate.show_sql false
hibernate.jdbc.batch_size 0
hibernate.jdbc.use_streams_for_binary true
Database is SAPDB 7.4.0.23.27, jdbc driver from sap.org, Implementation-Version: 7.4.4 Build 001-000-156-985
Please please tell me :
- my configuration is f@{#ed OR
- this is a known issue, solved in 2.1.1final OR
- I am dumb and doing something terribly wrong
Thank you,
Adrian