One possible method is to use a weakHashMap.  That way when there are no 
more class references to the object, it will be cleared up.

I haven't looked at the code, so I may be off base here.

WeakHashMap:
   http://java.sun.com/j2se/1.3/docs/api/java/util/WeakHashMap.html

Cheers,
Scott

-- 
Scott Farquhar :: [EMAIL PROTECTED]

Atlassian :: http://www.atlassian.com
      Supporting YOUR J2EE World


Steve Ebersole wrote:

> Is there a way to clear logger entries from the Hierarchy class's internal
> Hashtable?
> 
> The issue I am trying to get around deals with the way in which I am
> creating loggers for my User object.  The Logger is an instance variable and
> is created by: Logger.getLogger( "session." + user + "_" + session ).  The
> combination username plus HTTP session id will be pretty unique.  After
> looking through the code for LogManager, DefaultLoggerRepository, and
> Hierarchy I have seen no place where the loggers are ever cleaned up (once
> called they remain in the hierarchy's hashtable, thus preventing garbage
> collection).  I am afraid these log4j loggers will in essence become a
> memory-leak, "clearable" only when the VM is shutdown.
> 
> I understand that in the normal course/usage of log4j this is excatly what
> you probably want to happen.  But in my scenario, it can potentially be
> pretty detrimental.
> 
> Is there something I missed; someway to clear an individual entry from this
> hashtable?
> 
> If not, looks like I'll have to subclass or edit Hierarchy to add a
> removeLogger method.  What additional clean-up type methods should I call on
> the Logger in that case?
> Logger.removeAllAppenders()?
> Any others?
> 
> Thanks,
> Steve
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to