You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christian Kaufhold <ka...@googlemail.com> on 2012/05/24 14:21:33 UTC

memory leak in tomcat

Hi,

I have a leaking Tomcat App
I checked the heap with the Eclipse Memory Analyser
and it says

The classloader/component *"org.apache.catalina.loader.WebappClassLoader @
0x94532f50"*
occupies *376.421.152 (79,51%)* bytes. The memory is accumulated in one
instance of
*"java.util.HashMap$Entry[]"* loaded by *"<system class loader>"*.

and the data that is in the entries of the gigantic Map is
org.hibernate.impl.SessionFactoryObjectFactory

Does anyone know why this?

Christian




**
  Class Name Shallow Heap Retained Heap

   - java.util.HashMap$Entry[64] @ 0xaa9314c0 <mat://object/0xaa9314c0>

272 339.906.832 [image: \]

   - *table* java.util.HashMap @ 0xaa931498 <mat://object/0xaa931498>

40 339.906.872 [image: .][image: \]

   - *map* org.hibernate.util.FastHashMap @ 0x94e4bc98<mat://object/0x94e4bc98>

16 339.906.888 [image: .][image: .][image: \]

   - *INSTANCES* class org.hibernate.impl.SessionFactoryObjectFactory @
   0x759319f8 <mat://object/0x759319f8>

24 339.907.088 [image: .][image: .][image: .][image: \]

   - *[1788]* java.lang.Object[5120] @ 0x95148470 <mat://object/0x95148470>

20.496 375.206.992 [image: .][image: .][image: .][image: .][image: \]

   - *elementData* java.util.Vector @ 0x94538998 <mat://object/0x94538998>

24 375.207.016 [image: .][image: .][image: .][image: .][image: .][image: \]

   - *classes* org.apache.catalina.loader.WebappClassLoader @
0x94532f50<mat://object/0x94532f50>

176 376.421.152 [image: .][image: .][image: .][image: .][image:
.][image: .][image:
+]

   - *contextClassLoader* java.lang.Thread @ 0x94e1ac60
Thread-10<mat://object/0x94e1ac60>
   *Thread*

112 7.112 [image: .][image: .][image: .][image: .][image: .][image: .][image:
+]

   - *contextClassLoader* de.bfd.tools.ConnectionPool$ConnPoolMultiCaster @
   0x94e1ad00 Thread-9 <mat://object/0x94e1ad00> »

136 592 [image: .][image: .][image: .][image: .][image: .][image: .][image:
+]

   - *contextClassLoader* java.lang.Thread @ 0x9bb7b548
Keep-Alive-Timer<mat://object/0x9bb7b548>»

112 168 [image: .][image: .][image: .][image: .][image: .][image: .][image:
+]

   - *classloader* java.security.ProtectionDomain @
0x9453a160<mat://object/0x9453a160>»

Re: memory leak in tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Christian Kaufhold wrote:

> Hi,
> 
> I have a leaking Tomcat App
> I checked the heap with the Eclipse Memory Analyser
> and it says
> 
> The classloader/component *"org.apache.catalina.loader.WebappClassLoader @
> 0x94532f50"*
> occupies *376.421.152 (79,51%)* bytes. The memory is accumulated in one
> instance of
> *"java.util.HashMap$Entry[]"* loaded by *"<system class loader>"*.
> 
> and the data that is in the entries of the gigantic Map is
> org.hibernate.impl.SessionFactoryObjectFactory
> 
> Does anyone know why this?
> 

One giant leap in the dark and totally-uneducated guess : due to some logical or 
configuration error, this application creates a new session at each request, and they 
never time out ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: memory leak in tomcat

Posted by Christian Kaufhold <ka...@googlemail.com>.
Hi Warren,

thanks for the help. I found that the application
creates lots of SessionFactoryImpl objects
even though one is enough

I changed this part of webapp. Now it has only one
SessionFactoryImpl and the memory leak is gone.

bye

2012/5/24 Warren Bell <wa...@gmail.com>

> Is this the same server with the Wicket app you posted about earlier ?
> If so, you have a Wicket app that is storing the
> SessionFactoryObjectFactory on a page as a class member. Wicket stores
> each page a user has been to in the user's session. If the page has
> class members, then it serializes them and stores them too. I have seen
> this kind of thing happen many times before causing big memory usage.
>
> Remove the Wicket app and run the Eclipse Memory Analyzer.
>
> Thanks,
>
> Warren Bell
>
> On 5/24/12 5:42 AM, Konstantin Kolinko wrote:
> > 2012/5/24 Christian Kaufhold <ka...@googlemail.com>:
> >> Hi,
> >>
> >> I have a leaking Tomcat App
> >> I checked the heap with the Eclipse Memory Analyser
> >> and it says
> >>
> >> The classloader/component
> *"org.apache.catalina.loader.WebappClassLoader @
> >> 0x94532f50"*
> >> occupies *376.421.152 (79,51%)* bytes. The memory is accumulated in one
> >> instance of
> >> *"java.util.HashMap$Entry[]"* loaded by *"<system class loader>"*.
> >>
> >
> > So the memory is used for something useful? That is not a "memory
> > leak". It is just a web application requiring a lot of memory.
> >
> > WebappClassLoader is the classloader that is used to load the classes
> > of your webapp.  Of course, it remembers every class that it loaded
> > (to satisfy repeated class.forName() calls) and every class that it
> > loads has a reference it it (via getClass().getClassLoader()).
> >
> > There may be many classes, but I do not think that the classloader
> > itself is responsible for 300 Mb of memory.
> >
> >> and the data that is in the entries of the gigantic Map is
> >> org.hibernate.impl.SessionFactoryObjectFactory
> >>
> >
> > That would be a hibernate question. I have no clue what that class is
> about.
> >
> > Best regards,
> > Konstantin Kolinko
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: memory leak in tomcat

Posted by Warren Bell <wa...@gmail.com>.
Is this the same server with the Wicket app you posted about earlier ?
If so, you have a Wicket app that is storing the
SessionFactoryObjectFactory on a page as a class member. Wicket stores
each page a user has been to in the user's session. If the page has
class members, then it serializes them and stores them too. I have seen
this kind of thing happen many times before causing big memory usage.

Remove the Wicket app and run the Eclipse Memory Analyzer.

Thanks,

Warren Bell

On 5/24/12 5:42 AM, Konstantin Kolinko wrote:
> 2012/5/24 Christian Kaufhold <ka...@googlemail.com>:
>> Hi,
>>
>> I have a leaking Tomcat App
>> I checked the heap with the Eclipse Memory Analyser
>> and it says
>>
>> The classloader/component *"org.apache.catalina.loader.WebappClassLoader @
>> 0x94532f50"*
>> occupies *376.421.152 (79,51%)* bytes. The memory is accumulated in one
>> instance of
>> *"java.util.HashMap$Entry[]"* loaded by *"<system class loader>"*.
>>
> 
> So the memory is used for something useful? That is not a "memory
> leak". It is just a web application requiring a lot of memory.
> 
> WebappClassLoader is the classloader that is used to load the classes
> of your webapp.  Of course, it remembers every class that it loaded
> (to satisfy repeated class.forName() calls) and every class that it
> loads has a reference it it (via getClass().getClassLoader()).
> 
> There may be many classes, but I do not think that the classloader
> itself is responsible for 300 Mb of memory.
> 
>> and the data that is in the entries of the gigantic Map is
>> org.hibernate.impl.SessionFactoryObjectFactory
>>
> 
> That would be a hibernate question. I have no clue what that class is about.
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: memory leak in tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Konstantin,

On 5/24/12 8:42 AM, Konstantin Kolinko wrote:
> 2012/5/24 Christian Kaufhold <ka...@googlemail.com>:
>> Hi,
>> 
>> I have a leaking Tomcat App I checked the heap with the Eclipse
>> Memory Analyser and it says
>> 
>> The classloader/component
>> *"org.apache.catalina.loader.WebappClassLoader @ 0x94532f50"* 
>> occupies *376.421.152 (79,51%)* bytes. The memory is accumulated
>> in one instance of *"java.util.HashMap$Entry[]"* loaded by
>> *"<system class loader>"*.
>> 
> 
> So the memory is used for something useful? That is not a "memory 
> leak". It is just a web application requiring a lot of memory.
> 
> WebappClassLoader is the classloader that is used to load the
> classes of your webapp.  Of course, it remembers every class that
> it loaded (to satisfy repeated class.forName() calls) and every
> class that it loads has a reference it it (via
> getClass().getClassLoader()).
> 
> There may be many classes, but I do not think that the classloader 
> itself is responsible for 300 Mb of memory.

It may, if the ClassLoader holds references to Class objects (it does)
that contain static members with lots of data (not so sure about this
part).

>> and the data that is in the entries of the gigantic Map is 
>> org.hibernate.impl.SessionFactoryObjectFactory
> 
> That would be a hibernate question. I have no clue what that class
> is about.

+1

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk++T9YACgkQ9CaO5/Lv0PAwAQCfZSz67ALyFrRfZaVYs6Tjoee7
Q4UAnA/Q2vIjecxXPEW+BzsN7GeSJQk3
=zQcP
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: memory leak in tomcat

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/5/24 Christian Kaufhold <ka...@googlemail.com>:
> Hi,
>
> I have a leaking Tomcat App
> I checked the heap with the Eclipse Memory Analyser
> and it says
>
> The classloader/component *"org.apache.catalina.loader.WebappClassLoader @
> 0x94532f50"*
> occupies *376.421.152 (79,51%)* bytes. The memory is accumulated in one
> instance of
> *"java.util.HashMap$Entry[]"* loaded by *"<system class loader>"*.
>

So the memory is used for something useful? That is not a "memory
leak". It is just a web application requiring a lot of memory.

WebappClassLoader is the classloader that is used to load the classes
of your webapp.  Of course, it remembers every class that it loaded
(to satisfy repeated class.forName() calls) and every class that it
loads has a reference it it (via getClass().getClassLoader()).

There may be many classes, but I do not think that the classloader
itself is responsible for 300 Mb of memory.

> and the data that is in the entries of the gigantic Map is
> org.hibernate.impl.SessionFactoryObjectFactory
>

That would be a hibernate question. I have no clue what that class is about.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org