-->
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.  [ 1 post ] 
Author Message
 Post subject: Java heap space problem
PostPosted: Mon Aug 03, 2009 5:41 am 
Newbie

Joined: Mon Aug 03, 2009 5:00 am
Posts: 1
Hi,

We're using a JPA entity with a byte array that can be very large (> 50M). The entity is defined as follows:

Code:
@Entity
@Name("record")
@Scope(SESSION)
public class Record implements Serializable {

   private static final long serialVersionUID = 1491449501828459427L;

   @Id
   @GeneratedValue
   private int id;

   @Column(name="data", nullable=true, columnDefinition="BINARY")
   @Basic(fetch = FetchType.LAZY)
   private byte[] data = new byte[]{};

   ...
}


When working with the objects (I can potentially have several of those loaded) I often experience the exception below, a Java OutOfMemoryError.

I'm wondering if we're doing anything wrong in handling the object.

Is there a possibility to remove the object, or the byte array, from memory when I'm done with it? Setting it to null doesn't do the magic for me it seems to stay in memory (when observing the memory with 'top' for instance).

I've also set -Xmx to the highest possible value on my 32-bit ยด(Ubuntu) machine (1600m). So increasing the provided memory shouldn't be an option.

Is there any recommended hibernate procedure when working with large data objects? How to release references, tell Hibernate (and/or the JVM) to instantly release the object/memory?

We are using the following:

- JBoss Seam 2.0.2.SP1 on JBoss 4.2.2
- Hibernate 3.2.3.GA, Hibernate Annotations 3.3.0.GA

Any help or hints here are highly appreciated.

Thanks,
Hannes

Code:
Caused by: java.lang.OutOfMemoryError: Java heap space
   at org.hibernate.type.AbstractBynaryType.deepCopyNotNull(AbstractBynaryType.java:148)
   at org.hibernate.type.MutableType.deepCopy(MutableType.java:25)
   at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:353)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:181)
   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.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.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3042)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
   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.internalLoad(SessionImpl.java:846)
   at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
   at org.hibernate.type.EntityType.resolve(EntityType.java:379)
   at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:204)
   at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:708)
   at org.hibernate.collection.PersistentMap.readFrom(PersistentMap.java:258)
   at org.hibernate.loader.Loader.readCollectionElement(Loader.java:1008)
   at org.hibernate.loader.Loader.readCollectionElements(Loader.java:646)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:591)
   at org.hibernate.loader.Loader.doQuery(Loader.java:701)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)


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

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.