You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "mhstnsc (JIRA)" <ji...@apache.org> on 2018/01/19 09:08:00 UTC
[jira] [Created] (LOG4J2-2201) ReusableParametrizedMessages keeps
references to objects beyond their expected lifetime
mhstnsc created LOG4J2-2201:
-------------------------------
Summary: ReusableParametrizedMessages keeps references to objects beyond their expected lifetime
Key: LOG4J2-2201
URL: https://issues.apache.org/jira/browse/LOG4J2-2201
Project: Log4j 2
Issue Type: Bug
Components: API
Affects Versions: 2.8.2
Environment: Linux, ubuntu 14.04, java 8
Reporter: mhstnsc
During some memory leak analysis i noticed that one of my object which was expected to die was kept alive for longer than expected. The only reference to it was in ReusableParametrizedMessage
This object was pretty heavy and hold tens-hundreds of references to child object alive also.
I had to disable logging to test the leaks.
The side effect to this is:
# Holding the references longer than expected will move the memory from young generation to tenured generation where collection is more expensive and affect performance
# Debugging memory leaks just became harder.
ReusableParametrizedMessage should not hold references to objects beyond their intended lifetime
As you can see in this sample code
{code:java}
ReusableParameterizedMessage set(final String messagePattern, final Object p0) {
params[0] = p0;
init(messagePattern, 1, params);
return this;
}
ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1) {
params[0] = p0;
params[1] = p1;
init(messagePattern, 2, params);
return this;
}{code}
If i call set(pattern,p0,p1) and then set(pattern, p0) ...then reference to p1 is kept alive until overriden by another set.
I don't have an understanding about log4j inner workings but for me the references should be kept only for the duration of the call to log.
I would be happy to be able to disable the mechanism.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)