views:

598

answers:

2

I have enterprise app with EJB. The total size of the app is 34 meg. When i deploy my app everything is fine but when I redeploy it the number of total loaded classes increases. I'm using visualVM to see this info. So is it how it should be or it's a memory leak. How to solve this problem? Thanks

+1  A: 

You have a classloader leak!

You'll generally find that when you deploy an application on any JavaEE application server (including Glassfish), the application server will create a new classloader specifically for your application. When your application is initialized, and as it runs, that class loader will load new classes, which will be placed into permanent memory, referred to as the PermGen region.

When the application is undeployed, that classloader is supposed to be garbage-collected, but sometimes that doesn't happen because something is causing the reference to persist. When you redeploy your application, the application server goes through the same motions as before, but now, there is less memory available.

For more information on this, take a look at Frank Kieviet's blog post called Classloader Leaks and the follow-up on How to Fix Classloader Leaks.

David Grant
A: 

Visual VM is just the standalone edition of the "profiler" tool included in Netbeans.

So in order to detect your memory leak you should read the documention for the Netbeans profiler.

Here are some links to get you started

kazanaki