logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Goers (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-1142) ThreadLocals in Layout implementations should be non-static to prevent memory leaks in web containers
Date Sat, 03 Oct 2015 21:17:26 GMT

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

Ralph Goers edited comment on LOG4J2-1142 at 10/3/15 9:17 PM:
--------------------------------------------------------------

The numbers above don't correspond to what you posted in LOG4J2-935. Here with 1 thread the
objectPool was about 20 ns/op and in LOG4J2-935 it was about 12. newInstance was about the
same as here but threadLocal was about 14, not 19.

I would imagine that the ObjectPool performs worse in the 4 thread test do to lock contention,
which presumably the ThreadLocal doesn't have. However, in these tests all you are doing is
beating on the pool or ThreadLocal. In a "normal" environment contention for the lock is likely
to be much less of an issue.  Unfortunately, the only way I know of to test that is to actually
perform logging and add the overhead of the other stuff (perhaps without actually writing
to a file). I suspect that they will come out a wash based on what I saw when running "PerformanceComparison".


was (Author: ralph.goers@dslextreme.com):
The numbers above don't correspond to what you posted in LOG4J2-935. Here with 1 thread the
objectPool was about 20 ns/op and in LOG4J2-935 it was about 12. newInstance was about the
same as here but threadLocal was about 14, not 19.

> ThreadLocals in Layout implementations should be non-static to prevent memory leaks in
web containers
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1142
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1142
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Layouts
>    Affects Versions: 2.4
>            Reporter: Dmitri Blinov
>            Assignee: Remko Popma
>             Fix For: 2.4.1
>
>         Attachments: LOG4J2-1142.patch
>
>
> As discussed in LOG4J2-1125, storing ThreadLocal<StringBuilder> in a static field
may not interact well with the thread pools and class loaders of some web containers and may
result in memory leaks, especially in older web containers.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message