[ https://jira.qos.ch/browse/SLF4J-469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ceki Gülcü resolved SLF4J-469. ------------------------------ Resolution: Fixed Fixed in [commit 306d8fd2|https://github.com/qos-ch/slf4j/commit/306d8fd23d89b0a] on master and in [commit c6c7a98a7ee1|https://github.com/qos-ch/slf4j/commit/c6c7a98a7ee1e7138] on the 1.7 maintenance branch. > Potential memory leaks if there is no underlying implementation > --------------------------------------------------------------- > > Key: SLF4J-469 > URL: https://jira.qos.ch/browse/SLF4J-469 > Project: SLF4J > Issue Type: Bug > Affects Versions: 1.7.26 > Environment: java 8 > slf4j 1.7.26 > > Reporter: yu > Assignee: Ceki Gülcü > Priority: Critical > Labels: logging, substitution > Fix For: 2.0.0-alpha2, 1.7.30 > > > > *If I don't have 'logback' 'log4j'...... Implementation class* > The problem lies in the method > *public static ILoggerFactory getILoggerFactory()* > first Thread1: > {code:java} > if (INITIALIZATION_STATE == UNINITIALIZED) { > init..... > } > {code} > secode Thread2: > {code:java} > case ONGOING_INITIALIZATION: > return SUBST_FACTORY;{code} > obtained "SUBST_FACTORY", > and obtained "SubstituteLogger" > > third: > Thread1: > {code:java} > //init failed cache "NoClassDefFoundError" > INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION; > {code} > *The SubstituteLogger obtained by Thread2 will always output the log to the > queue until the memory overflows.* > {code:java} > // code placeholder > synchronized public Logger getLogger(String name) { > SubstituteLogger logger = loggers.get(name); > if (logger == null) { > logger = new SubstituteLogger(name, eventQueue, postInitialization); > loggers.put(name, logger); > } > return logger; > } > public void info(String msg) { > delegate().info(msg); > } > Logger delegate() { > if(_delegate != null) { //_delegate== null forever > return _delegate; > } > if(createdPostInitialization) { createdPostInitialization == false > forever > return NOPLogger.NOP_LOGGER; > } else { > return getEventRecordingLogger(); > } > } > {code} > > > > -- This message was sent by Atlassian JIRA (v7.3.1#73012) _______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-dev