Archie Cobbs wrote:
> Jeroen Frijters wrote:
> > There are several places in our codebase were we need/want to cache
> > stuff that is associated with a class or class loader. 
> Currently these
> > places retain a strong reference to the class loader, which is not
> > correct, because the class loader should be garbage collectable.
> > 
> > I cooked up proposal for an API to use for this and 
> implemented it in
> > the three places I could think of off the top my head 
> (serialization,
> > proxy and resource bundle).
> > 
> > This is just a first stab, so no documentation and no 
> change log entry
> > yet. Please comment on the idea and/or the API.
> 
> Dumb question.. why wouldn't it work to just use a WeakHashMap instead
> of a HashMap in all those places?

Not a dumb question at all. That *would* work. The "problem" is that (at
least on some runtimes) WeakHashMap is much more expensive than this
approach.

Regards,
Jeroen

Reply via email to