commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject [logging] Memory leak - replace Hashtable with WeakHashMap in LogFactory?
Date Thu, 15 May 2003 10:38:15 GMT
when i was working on test cases for beanutils, i released that LogFactory 
keeps a strong reference to the context classloader. this prevents any 
context classloader for a thread which calls LogFactory.getLog() from 
being garbage collected.

LogFactory users a hashtable to index context classloaders. i think (at 
least for those people running JVMs where WeakHashMap works correctly) 
that this could be fixed by replacing Hashtable with a WeakHashMap.

the only reason i can see for using Hashtable (rather than WeakHashMap) is 
that it allows logging  to be used in a java 1.1 JVM. the PROPOSAL.html 
lists java 1.1 but STATUS.html gives java 1.2. the feature (per 
classloader instances) is likely only to be used with a 1.2 JVM so i'd 
rather make sure that it works correctly and then think about a separate 
version without this feature for 1.1 JVMs.

so on balance, i think that changing hashtable to WeakHashMap is a good 
idea. if anyone disagrees, they need to shout up now.

- robert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message