logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luca boncompagni <lbo...@gmail.com>
Subject Re: issue with org.apache.logging.log4j.core.layout.AbstractStringLayout.getStringBuilder()
Date Fri, 11 Mar 2016 20:08:44 GMT
Il 11/mar/2016 20:17, "Gary Gregory" <garydgregory@gmail.com> ha scritto:
>
> On Fri, Mar 11, 2016 at 8:38 AM, luca boncompagni <lbonco@gmail.com>
wrote:
>>
>> Hi to all,
>>
>> I'm using lo4j2-2.5 and I have some memory usage problems with
>> AbstractStringLayout.getStringBuilder(). If I write a very long line
>> of log, the memory used by this line of log is never cleaned.
>>
>> In the code, I see result.setLength(0) that sets the current size to
>> 0, but the buffer of the string builder remains as long as it is.
>>
>> Should be ok to use something like this:
>>
>> result.setLength(0);
>> result.setLength(DEFAULT_STRING_BUILDER_SIZE);
>> result.trimToSize();
>>
>> I have another question, why we should use a threadlocal to get an
>> empty StringBuilder?
>
>
> Performance. It saves a lot of time and memory to avoid creating a new
StringBuilder for each log event.
>
> Gary

Ok, I'll do some test.

Can you help me about memory usage?

Luca

Mime
View raw message