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

Gary Gregory commented on LOG4J2-1122:
--------------------------------------

Thank you for your report Leonid.

What do you mean by "dymanic configuration"? 

Do you have a unit test we can use?

Finally, what are you proposing?
- That we add a remove logger API?
- The we use a weak reference map to track loggers?
- Something else?

Gary

> 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