velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulo Gaspar" <paulo.gas...@krankikom.de>
Subject Multiple-ClassLoader safe Introspector
Date Mon, 10 Sep 2001 15:01:08 GMT
There is a simple way of having a Multiple-ClassLoader safe Introspector:
  LRU cache.

There are a couple of LRU Maps/caches in Jakarta. The simplest one I am 
aware of is the LRUMap at the commons-collections project (I have a 
lighter/faster version of this one in tests.)

If one finds an appropriate strategy to evict unused introspection data
from the cache, everything will end up being GCed "sometime" (albeit 
possibly quite a bit after the respective CL is invalidated).

Possible strategies to trigger eviction:
 - When free memory gets lower than X (that is how Cocoon 2's 
   MRUMemoryStore triggers eviction of cached objects);
 - Time interval.


Possible strategies to find out how many objects to evict:
 - Until free memory goes back to acceptable levels (again, as in 
   Cocoon 2's MRUMemoryStore);
 - Introspected data not used for more than Y minutes.


It would also be nice to have an API call just to evict all cached 
introspection data for a given ClassLoader.


Disadvantages: 
  * Added configuration complexity of the Introspection Cache;
  * Maybe it would be slightly slower (just the time of moving updating
    the LRU list for each use).
    

Advantages:
  * It is possible to use a single cache for multiple class loaders and
    even for multiple "legal" versions of the same class.

I do not talk about complexity because a simplistic Cache based on a 
LRUMap with a time based eviction strategy would be even simpler than 
the new cache.


Again, it would be nice to change Introspection Cache implementations 
at will. Maybe an idea for version 2... or 3...


Have fun,
Paulo Gaspar


Mime
View raw message