Re: MDC does not properly clean up

2010-10-18 Thread Marcel Stör

On 24.09.10 17:04, Jacob Kjome wrote:

Since Log4j must support JDK1.4 (actually, still 1.3, I believe), I
don't see how we could use JDK1.5+ ThreadLocal.remove()?

That said, there are other ways of cleaning up ThreadLocals that don't
require remove().  For examples, see CrazyBob's "Hard Core Java:
ThreadLocal" from back in 2006 [1].  Log4j could utilize CrazyBob's
suggestions and provide an MDC cleanup method to allow users a chance to
clean up.  Thoughts?


logback apparently had the same issue. It was fixed a few hours ago: 
http://jira.qos.ch/browse/LBCLASSIC-183



Also, for reference, I thought I'd provide a link to what the
commons-lang guys did to fix their memory leaks, though keep in mind it
depends on the JDK1.5+ ThreadLocal.remove() method [2].  They also use a
WeakHashMap, which I'm not sure is necessary or not for Log4j's purposes?


[1] http://blog.crazybob.org/2006/07/hard-core-java-threadlocal.html
[2]
https://fisheye6.atlassian.com/browse/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java#r907126


Jake

On Fri, 24 Sep 2010 09:24:10 +0200
Marcel Stör  wrote:

The initial problem description was sent to the users list:
http://www.mail-archive.com/log4j-u...@logging.apache.org/msg11921.html

However, I think it actually belongs here...

I believe that the MDC should provide a method that internally calls
ThreadLocal#remove which was added to the API with Java5:
http://download.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html#remove%28%29


Other libraries/frameworks start fixing their issues with this, too:
- https://issues.apache.org/jira/browse/LANG-586
- https://jira.springsource.org/browse/SPR-7441
- https://jira.springsource.org/browse/SEC-1578


--
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org



Re: MDC does not properly clean up

2010-09-30 Thread Marcel Stör
On 24.09.2010, at 17:04, Jacob Kjome wrote:
> Since Log4j must support JDK1.4 (actually, still 1.3, I believe), I don't see 
> how we could use JDK1.5+ ThreadLocal.remove()?

I suspected something like this...I was actually surprised to see that there's 
still development activity here.
What I see sometimes with other libraries which have similar constraints is 
that they detect JVM versions and act accordingly (in some cases issuing 
commands via reflection). 

> That said, there are other ways of cleaning up ThreadLocals that don't 
> require remove().  For examples, see CrazyBob's "Hard Core Java: ThreadLocal" 
> from back in 2006 [1].  Log4j could utilize CrazyBob's suggestions and 
> provide an MDC cleanup method to allow users a chance to clean up.  Thoughts?

From a client application developer's point of view there should be "some 
means" to clear this that works reliably on somewhat modern JVMs. Please note 
that
- Tomcat only runs its clean-up operations when it runs on Sun JVMs
- only Sun JVMs seem to have that memory issue because they load classes into 
permgen
- not clearing MDC ThreadLocal only becomes an issue when frequently 
hot-deploying an application in a container (something you don't wanna do in 
production environments anyway)

As a client application developer I care because customers are breathing down 
our neck to get this fixed nonetheless.

Marcel

-- 
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org


-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org



Re: MDC does not properly clean up

2010-09-24 Thread Jacob Kjome
Since Log4j must support JDK1.4 (actually, still 1.3, I believe), I don't see 
how we could use JDK1.5+ ThreadLocal.remove()?


That said, there are other ways of cleaning up ThreadLocals that don't require 
remove().  For examples, see CrazyBob's "Hard Core Java: ThreadLocal" from 
back in 2006 [1].  Log4j could utilize CrazyBob's suggestions and provide an 
MDC cleanup method to allow users a chance to clean up.  Thoughts?


Also, for reference, I thought I'd provide a link to what the commons-lang 
guys did to fix their memory leaks, though keep in mind it depends on the 
JDK1.5+ ThreadLocal.remove() method [2].  They also use a WeakHashMap, which 
I'm not sure is necessary or not for Log4j's purposes?



[1] http://blog.crazybob.org/2006/07/hard-core-java-threadlocal.html
[2] 
https://fisheye6.atlassian.com/browse/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java#r907126


Jake

On Fri, 24 Sep 2010 09:24:10 +0200
 Marcel Stör  wrote:
The initial problem description was sent to the users list: 
http://www.mail-archive.com/log4j-u...@logging.apache.org/msg11921.html


However, I think it actually belongs here...

I believe that the MDC should provide a method that internally calls 
ThreadLocal#remove which was added to the API with Java5:

http://download.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html#remove%28%29

Other libraries/frameworks start fixing their issues with this, too:
- https://issues.apache.org/jira/browse/LANG-586
- https://jira.springsource.org/browse/SPR-7441
- https://jira.springsource.org/browse/SEC-1578

Regards,
Marcel

P.S. I'm using the slf4j MDC but AFAIK it simply delegates to log4j.

--
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org





-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org



MDC does not properly clean up

2010-09-24 Thread Marcel Stör
The initial problem description was sent to the users list: 
http://www.mail-archive.com/log4j-u...@logging.apache.org/msg11921.html


However, I think it actually belongs here...

I believe that the MDC should provide a method that internally calls 
ThreadLocal#remove which was added to the API with Java5:

http://download.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html#remove%28%29

Other libraries/frameworks start fixing their issues with this, too:
- https://issues.apache.org/jira/browse/LANG-586
- https://jira.springsource.org/browse/SPR-7441
- https://jira.springsource.org/browse/SEC-1578

Regards,
Marcel

P.S. I'm using the slf4j MDC but AFAIK it simply delegates to log4j.

--
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org