On Fri, Mar 11, 2016 at 8:38 AM, luca boncompagni <[email protected]> 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

>
> Regards,
> Luca
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to