[logback-dev] [JIRA] Resolved: (LBCORE-49) LogbackMDCAdapter allocates new HashMap for every MDC call

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Mon Oct 27 23:23:21 CET 2008

     [ http://jira.qos.ch/browse/LBCORE-49?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ceki Gulcu resolved LBCORE-49.

    Fix Version/s: unspecified
       Resolution: Won't Fix


I do not wish to change the code to support special use cases, especially because I think it would be easy to implement an alternative MDC implementation without the "copy on modify" behavior, say XMDC.

Once you have written XMDC, you would also need an XMDCConverter. Assuming that you do not wish to serialize XMDC values in the LoggingEvent, those would be the only two required additions, i.e. approx. 1 hour of work.

You could add XMDC values to LoggingEvent by modifying its argument array. For example, if you converted the XMDC key/value  pairs into strings, adding them to the event's argument array would have them serialized in the event. Anyway, if you wish to pursue this venue, we could work on a more elegant way on extending the LoggingEvent object.

Please create a new issue if extending LoggingEvent is a path you would wish to explore.

> LogbackMDCAdapter allocates new HashMap for every MDC call
> ----------------------------------------------------------
>                 Key: LBCORE-49
>                 URL: http://jira.qos.ch/browse/LBCORE-49
>             Project: logback-core
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: unspecified
>         Environment: Operating System: All
> Platform: All
>            Reporter: Matt Finn
>            Assignee: Logback dev list
>             Fix For: unspecified
>         Attachments: mdc-diff.txt
> A new HashMap is allocated in logback's MDC implementation for every call to MDC.put and MDC.remove. 
> This can lead to excessive garbage collector load in performance critical code that makes very frequent use of MDC, such as asynchronous network and file IO code. 
> For certain programs it is critical to have MDC capability in code hotspots, where MDC is a valuable debugging tool as applied to TRACE and DEBUG statements. 
> The current implementation causes a load on the garbage collector even when logging is turned off.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list