You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by robert burrell donkin <ro...@blueyonder.co.uk> on 2003/05/15 12:38:15 UTC

[logging] Memory leak - replace Hashtable with WeakHashMap in LogFactory?

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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org