-->
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.  [ 6 posts ] 
Author Message
 Post subject: Memory leak (testcase included)
PostPosted: Wed Nov 23, 2005 6:55 pm 
Beginner
Beginner

Joined: Wed Sep 28, 2005 5:30 pm
Posts: 25
Hibernate version: 3.0.5

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="hibernate">
 
  <class name="ParentClass">
    <id name="id" type="long">
      <generator class="native"/>
    </id>
    <discriminator column="discriminator"/>
    <version name="version"/>

    <subclass name="ChildClass"/>
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
SessionFactory factory = new Configuration().configure("/jdbc.cfg.xml").buildSessionFactory();
Session session = factory.openSession();
ParentClass parent = (ParentClass) session.load(ParentClass.class, 1L);
Hibernate.initialize(parent);
ChildClass child = (ChildClass) session.get(ChildClass.class, 1L);
parent = null;
child = null;
session.clear();
session.close();
factory.close();
while (true)
{
Thread.sleep(1000);
System.gc();
}

Name and version of the database you are using:
MySQL 4.1.14-nt

Class definitions
Code:
package hibernate;
import java.io.Serializable;

public class ParentClass implements Serializable
{
  private Serializable id;
  private Serializable version;
 
  public Serializable getId()
  {
    return id;
  }
 
  public void setId(Serializable id)
  {
    this.id = id;
  }
 
  public Serializable getVersion()
  {
    return version;
  }
 
  public void setVersion(Serializable version)
  {
    this.version = version;
  }
}

package hibernate;
public class ChildClass extends ParentClass
{}


Database rows
Ensure there is a single row in the database of type ChildClass, with id=1

-------

I am using JProfiler for memory profiling and I can see that when the code reaches the never-ending loop, there is an instance of ChildClass resident in memory with a reference from CGLIBLazyInitializer. My expectation is for all instances of ParentClass and ChildClass to be non-referenced after session.clear() is invoked.

My actual application uses Query.iterate() for bulk processing operations and it runs out of memory because Session.clear() is not releasing all references as expected.

I welcome your help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 7:32 pm 
Beginner
Beginner

Joined: Wed Sep 28, 2005 5:30 pm
Posts: 25
I can't reproduce this issue in Hibernate 3.1 rc3 so I think it has been fixed.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 9:55 am 
Regular
Regular

Joined: Sat Nov 05, 2005 5:33 am
Posts: 70
Location: Linz, Austria
If I remember correctly there was some other thread that also pointed in this direction.
It was sovled by calling refresh after the clear.

Regards,
Heinz


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 10:06 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
try to upgrade cglib, there is a bug in cglib version distributed with hibernate 3.05


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 11:31 am 
Beginner
Beginner

Joined: Wed Sep 28, 2005 5:30 pm
Posts: 25
baliukas wrote:
try to upgrade cglib, there is a bug in cglib version distributed with hibernate 3.05


I also read about a CGLIB bug so I CGLib from Hibernate 3.0.5 inside Hibernate 3.1 rc3 and the issue still occured. So, I don't think this was a CGLIB issue. Furthermore, the page that discussed the CGLIB said that it was fixed in CGLIB 2.1.3 and H3.1 only uses CGLIB 2.1.2 so I don't think it is fixed in that yet. I assume there are plans for upgrading H3.1 to CGLIB 2.1.3?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 12:05 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It is related to some changes in hibernate 3.1 too, but
just use CGLIB 2.1.3, it must work with all hibernate versions (including hibernate 2). CGLIB maintaince releases contain bug fixes and optimizations only, it must be safe (and recommended) to upgarde.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.