[ 
https://issues.apache.org/jira/browse/LOG4J2-1122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14744293#comment-14744293
 ] 

Ralph Goers commented on LOG4J2-1122:
-------------------------------------

My guess is that they must have code that generates dynamic logger names.  A 
strange use case, but then I could see why this would matter. I'm really not 
sure why anyone would do that though.


> Memory leak with dymanic configuration.
> ---------------------------------------
>
>                 Key: LOG4J2-1122
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1122
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.2, 2.3
>            Reporter: Leonid Kazantsev
>
> There are put to 
> {code}private final ConcurrentMap<String, Logger> loggers = new 
> ConcurrentHashMap<String, Logger>();
> at LoggerContext
> {code}
> But there is no remove, that's cause memory leak when using dynamic 
> configuration. Removing logger from configuration is not removing that logger 
> from context. 
> Also there is no right way to remove it from context.
> I'm using simple workaround for that issue:
> {code}
> LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
> Field field = LoggerContext.class.getDeclaredField("loggers");
> field.setAccessible(true);
> ConcurrentMap<String, Logger> loggers = (ConcurrentMap<String, Logger>) 
> field.get(ctx);
> loggers.remove(loggerName);
> {code}
> Memory leak ~ 1Mb/5000 loggers.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to