-->
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.  [ 9 posts ] 
Author Message
 Post subject: Thousands of classes generated by CGLIB
PostPosted: Mon Nov 17, 2003 3:55 am 
Newbie

Joined: Mon Nov 17, 2003 3:47 am
Posts: 2
Hello!

Using hibernate 2.1 beta 6.

I profiled my app because I got OutOfMemoryError after some redeployments within JBoss app server (3.2.2).

Looking with the profiler I see some strange things happening.

For example: My app contains a persistent class called com.select.adsystem.model.Element. After the app is deployed, Hibernate configuration is processed and some persistence operations are performed, memory profiler reports several classes that only have one instance allocated and all look like that:

com.select.adsystem.model.Element$$ProxiedByCGLIB$$82
com.select.adsystem.model.Element$$ProxiedByCGLIB$$81
com.select.adsystem.model.Element$$ProxiedByCGLIB$$8006
com.select.adsystem.model.Element$$ProxiedByCGLIB$$8005
com.select.adsystem.model.Element$$ProxiedByCGLIB$$8004
com.select.adsystem.model.Element$$ProxiedByCGLIB$$8003
com.select.adsystem.model.Element$$ProxiedByCGLIB$$8002
com.select.adsystem.model.Element$$ProxiedByCGLIB$$8001
com.select.adsystem.model.Element$$ProxiedByCGLIB$$8000
com.select.adsystem.model.Element$$ProxiedByCGLIB$$80
com.select.adsystem.model.Element$$ProxiedByCGLIB$$7999
...
...

... the strange thing being that there are more that 4000 of them. Is this realy what it is supposed to be happening? Are they all different? If they are all the same, there should be some cache preventing from generating a new class just to instantiate only one object of it. If they are different it seems that this is a strange design. Or maybe this is just a bug.


Regards, Peter


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 4:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There is a lazy proxy for each field of the class.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 4:26 am 
Newbie

Joined: Mon Nov 17, 2003 3:47 am
Posts: 2
david wrote:
There is a lazy proxy for each field of the class.


Ok, but I don't have 4000+ fields in my Element class.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 4:59 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
There is something broken.
Cglib fails to find generated class in cache. It can be caused by some bug in LazyInitializer implementation (All parameters to "enhance" must implement "equals/hashCode" for cache).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 5:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Sorry, Juozas - could you explain a bit further?

enhance() takes some classes, a class loader and a MethodInterceptor.

Class + ClassLoader already implement equals()/hasCode(), presumably (well, unless the ClassLoader doesn't, I suppose).

I don't have to implement equals()/hashCode() on the MethodInterceptor do I? That makes no sense.....


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 5:56 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
No MethodInterceptor doe's not need to implemet it, Filter implementation must implement it (if not singleton).
It can be something broken in cglib too, have you changed cglib version in hibernate 2.1 beta 6 ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 6:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Filter implementation must implement it (if not singleton)


Whats a Filter?

Quote:
have you changed cglib version in hibernate 2.1 beta 6


No, not for five months.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 6:17 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Filter can be used to strip not interesting methods (default is to accept all methods).

It will be something more interesting , if this code was not changed (possible classloader implementation), cache is tested in cglib.

"Hot fix" can be cache in LazyInitilizer implemention, it must be very trivial to implement for hibernate use case (sole "class" key for synchronized WeakHashMap must work).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 1:32 pm 
Beginner
Beginner

Joined: Fri Aug 29, 2003 3:39 pm
Posts: 33
Location: San Francisco, CA
AFAIK Hibernate does not use a ClassFilter so I'm not sure what's going on here. Hopefully the switch CGLIB2 will make it go away (only uses 2 classes per type, instead of 1+N) but it does seem like there is an underlying ClassLoader bug or something.


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