2016-03-17 138 views
-1

在我的應用我有一個堆內存例外:我增加與JVM參數堆內存,但它並沒有解決問題: 這裏是例外:Java堆內存休眠

`java.lang.OutOfMemoryError: Java heap space 
at org.hibernate.type.ByteArrayBlobType.deepCopy(ByteArrayBlobType.java:76) 
at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:374) 
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:184) 
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854) 
at org.hibernate.loader.Loader.doQuery(Loader.java:729) 
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) 
at org.hibernate.loader.Loader.loadCollection(Loader.java:1994) 
at org.hibernate.loader.collection.BatchingCollectionInitializer.initialize(BatchingCollectionInitializer.java:52) 
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565) 
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:63) 
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716) 
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454) 
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:844) 
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241) 
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860) 
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) 
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42) 
at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:82) 
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049) 
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399) 
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375) 
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139) 
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195) 
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103) 
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) 
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) 
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) 
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:519) 
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) 
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) 
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:512) 
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:506) 
` 

請幫助謝謝提前

+0

也許某些惡意實體映射(導致循環引用) – Antoniossss

+0

您可以粘貼Session初始化和查詢執行的代碼嗎? –

+0

請檢查與您同樣問題的其他問題。也許是相同的原因:http://stackoverflow.com/questions/30234995/hibernate-java-lang-outofmemoryerror-java-heap-space –

回答

0

檢查您是否通過某種單例機制獲取SessionFactory的實例。當我開始學習hibernate時,我遇到了這個問題。您可以使用jconsole來檢查jvm的性能。在命令提示符下鍵入jconsole並檢查性能變化並優化代碼