Hibernate Performance: Memory leak

JianJunShen
JianJunShen used Ask the Experts™
on
Hi: I am investigating a Spring, Hibernate application performance issue. The application runs on Linux machine with Tomcat. We have server around 10 G JVM memory. (64 bit CPU). I use a script tool to check some operation memory usage. For one operation, it takes 2Mega - 40 Mega. Normal operation takes 2-4 mega. And we do not have so many users. Peak time, 1 minute has 49 operations. But the server is down every a couple of days and saying out of memory.

My questions is as follows:

1) Is every operation taking 2-4 M too big in our case?
2)The maximum operation (40M)  loads 20,000 records from database. That is quite sure needing enhancement. But that alone is not a disaster to the server. Am I right?
3) MOST IMPORTANT: Are there some possibility that there is hibernate memory leak problem? Or our codes have memory leak problem? If so, are there some tool could check JVM's memory leak level?

Other comments on performance is also welcomed.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mick BarryJava Developer
Top Expert 2010
Commented:
1) would seem excessive, but hard to say without knowing whats going on
2) depends how often it occurs :)
3) could well be, and also leaks in tomcat

Mick BarryJava Developer
Top Expert 2010
Commented:
As you appear to have lots of database activity make sure you have your caching configured correctly.
Commented:
A leak in Hibernate is less likely than a leak either in a JDBC driver (especially if it's some obscure open source database) or your own application.

You'd need to do some serious profiling to find out for sure where to look though. What it sounds like at first glance is that you're keeping a lot of data in memory after it's no longer needed.
Either your cache timeout is excessively long for relatively volatile data, you're having a servlet hold on to Lists of retrieved records that are no longer needed (do you have a static Map or List somewhere that's growing out of control? Most likely something like a List of Lists of retrieved data), or you keep sessions open far too long containing Lists of records.
If those records contain BLOBs it only gets worse as those can get rather big.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Author

Commented:
I am using MySQL. I have no cache in this application. Yes, there are list of list. How to do profiling, are there step by step guide?
Mick BarryJava Developer
Top Expert 2010
Commented:
any reason for not having any caching?  by the sound of it you could get good value from some caching.

Author

Commented:
In the hibernate layer, the former developer using auto generated id as key in HashCode and equal method. Cache would not work in the application. I am not going to modify all hibernate layer, this could be too big tasks.
Mick BarryJava Developer
Top Expert 2010
Commented:
that can cause more problems than just caching. And it doesn't stop you caching altogether as you can use whatever key you want.

Author

Commented:
In this application, Object has many one to many or many to many relationship with other objects. It has a lot of lists. How to find memory leak because of lists? Are there any tool?


Author

Commented:
What's more, there are trianle many to many relationship among classes. One element has 17 one to many or many to many relationship with other classes.
Mick BarryJava Developer
Top Expert 2010
Commented:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial