[Bug 266] New: Memory Leak: Clearing MDC context with Log4J

http://bugzilla.slf4j.org/show_bug.cgi?id=266 Summary: Memory Leak: Clearing MDC context with Log4J Product: SLF4J Version: 1.6.x Platform: All OS/Version: All Status: NEW Severity: major Priority: P1 Component: Implementations AssignedTo: slf4j-dev@qos.ch ReportedBy: f.bantner@axon-e.de Recently after a long time log4j got it's problem with clearing the MDC context and the underlying ThreadLocal Hashmap fixed. S. https://issues.apache.org/bugzilla/show_bug.cgi?id=50486 This fixed a long running Problem with Tomcat freeing memory on reload. In order to do so, log4j's MDC got the clear method with 1.2.16 and with 1.2.17 fixed it so that it works. Log4j has an MDC adaptor for Log4J and it's own clear method. But instead of calling Log4J's clear it implements essentially (MDC.getContext()).clear() which only clears the HashMap but doesn't remove it from the ThreadLocal context resulting in a MemroryLeak. Short workaround: Instead of calling slf4j's MDC.clear() call log4j's MDC.clear() (but that is the exact opositit of what slf4j is made for) Simple Fix: change log4j's mdc adaptor to call MDC.clear() instead of MDC.getContext().clear(). More complex fix: If backward compatibility is an issue (like it was für log4j) than log4js solution can be applied here: Instead of calling MDC.clear() directly call it via reflexion if it exists and otherwise keep calling MDC.getContext().clear(). -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.

http://bugzilla.slf4j.org/show_bug.cgi?id=266 Olivier Ceulemans <olivier.ceulemans@iriscorporate.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |olivier.ceulemans@iriscorpo | |rate.com -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.

http://bugzilla.slf4j.org/show_bug.cgi?id=266 Marcel <marcel@frightanic.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marcel@frightanic.com --- Comment #1 from Marcel <marcel@frightanic.com> --- No feedback in more than 2 years? Isn't this considered important? Even though we use slf4j throughout the entire code base we still have to use the log4j MDC directly due to this bug. -- You are receiving this mail because: You are the assignee for the bug.

Marcel, is there an associated Pull Request at GitHub? From: "bugzilla-daemon@qos.ch<mailto:bugzilla-daemon@qos.ch>" <bugzilla-daemon@qos.ch<mailto:bugzilla-daemon@qos.ch>> Reply-To: slf4j developers list <slf4j-dev@qos.ch<mailto:slf4j-dev@qos.ch>> Date: Thursday, September 25, 2014 at 2:29 AM To: "slf4j-dev@qos.ch<mailto:slf4j-dev@qos.ch>" <slf4j-dev@qos.ch<mailto:slf4j-dev@qos.ch>> Subject: [slf4j-dev] [Bug 266] Memory Leak: Clearing MDC context with Log4J Marcel<mailto:marcel@frightanic.com>changed bug 266<http://bugzilla.slf4j.org/show_bug.cgi?id=266> What Removed Added CC marcel@frightanic.com<mailto:marcel@frightanic.com> Comment # 1<http://bugzilla.slf4j.org/show_bug.cgi?id=266#c1> on bug 266<http://bugzilla.slf4j.org/show_bug.cgi?id=266> from Marcel<mailto:marcel@frightanic.com> No feedback in more than 2 years? Isn't this considered important? Even though we use slf4j throughout the entire code base we still have to use the log4j MDC directly due to this bug. ________________________________ You are receiving this mail because: * You are the assignee for the bug. [http://elasticpath.com/images/ep.gif] Matthew Bishop, Senior Architect Mobile: +1-604-218-8102 Email: Matthew.Bishop@elasticpath.com<mailto:Matthew.Bishop@elasticpath.com> Elastic Path Software Inc. Web elasticpath.com <http://www.elasticpath.com/> | Blog getelastic.com <http://www.getelastic.com/> | Twitter twitter.com/elasticpath <http://www.twitter.com/elasticpath> Careers elasticpath.com/jobs<http://www.elasticpath.com/jobs> | Community grep.elasticpath.com <http://grep.elasticpath.com/> Confidentiality Notice: This message is intended only for the use of the designated addressee(s), and may contain information that is privileged, confidential and exempt from disclosure. Any unauthorized viewing, disclosure, copying, distribution or use of information contained in this e-mail is prohibited and may be unlawful. If you received this e-mail in error, please reply to the sender immediately to inform us you are not the intended recipient and delete the email from your computer system.
participants (2)
-
bugzilla-daemon@qos.ch
-
Matthew Bishop