[logback-dev] [JIRA] Commented: (LBCLASSIC-172) Use WeakHashMap instead of Hashtable in LoggerContext
Ceki Gulcu (JIRA)
noreply-jira at qos.ch
Tue Dec 15 18:17:33 CET 2009
[ http://jira.qos.ch/browse/LBCLASSIC-172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11463#action_11463 ]
Ceki Gulcu commented on LBCLASSIC-172:
--------------------------------------
The original test code takes ages before it throws an exception. this one gets there in a minute or two.
public static void main(String[] args) {
for (int i = 0; i < 10000000; i++) {
LoggerFactory.getLogger("Foo." + (i%117)+"."+(i%19)+"."+(i%23)+"."+(i%13)+"."+i);
if (i % 10000 == 0) {
System.out.println("i=" + i);
}
}
}
Without tweaking the JVM, the above code stopped after creating 2.7Million loggers.
Anyway, another thing to consider which makes it the whole issue really painful is that whenever the level of a logger is changed, the logger propagates this information to its child loggers. If you look at the code this results in nanosecond computational time for the evaluation of the effective logger level. However, when parent loggers reference their children, the children cannot be garbage collected. Unless of course the referencing is done using weak references.
Frankly, making loggers garbage-collectible is not worth the effort, an effort which is pretty damn substantial and without necessarily clear cut advantages.
> Use WeakHashMap instead of Hashtable in LoggerContext
> -----------------------------------------------------
>
> Key: LBCLASSIC-172
> URL: http://jira.qos.ch/browse/LBCLASSIC-172
> Project: logback-classic
> Issue Type: Bug
> Components: Other
> Affects Versions: 0.9.18
> Reporter: Joern Huxhorn
> Assignee: Logback dev list
> Fix For: unspecified
>
>
> Preventing garbage-collection of unused Loggers is a bad idea.
> The following code should not fail:
> for(int i=0;i<10000000;i++) {
> LoggerFactory.getLogger("Foo."+i).debug("Foo!");
> }
--
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