velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Attila Szegedi" <szege...@freemail.hu>
Subject Re: performance questions
Date Fri, 07 Sep 2001 10:57:31 GMT

----- Original Message -----
From: "Geir Magnusson Jr." <geirm@optonline.net>
To: <velocity-user@jakarta.apache.org>
Sent: 2001. szeptember 7. 0:03
Subject: Re: performance questions


>
> I am not sure what happens with Tomcat's classloader when you load a new
> jar.  I would think that if it's just your servlet, then the Velocity
stuff
> wouldn't need to change.  The template cache will hold what it has.  The
> introspector might accumulate gunk over time, but I wouldn't think that
> would be significant amounts of memory.  I assume that the JAR only
contains
> code?
>

Introspector holds a strong reference to Class objects, so it prevents them
from being unloaded. This way, not only does it accumulate method cache
information, but it also keeps those classes around together with their code
and every object reachable from their static fields. And that can impose a
significant memory leak in an environment where classes are reloaded
frequently.

This could be fixed with employment of weak references and removal of
superfluous strong references:
- using WeakHashMap instead of Hashtable for Introspector.classMethodMaps
- removing the clazz field from ClassMap (it could be passed on as a
parameter from constructor to populateMethodCache(), and no other method
references it). This is worth doing regardless of other suggestions.
- using WeakReference containing Method as values in ClassMap.methodCache
- using WeakReference containing Method as elements of list stored in
MethodMap.methodByNameMap

If people are comfortable with these changes, I can do them.
Attila.


Mime
View raw message