You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Kevin Andrew Meurer (JIRA)" <ji...@apache.org> on 2018/07/11 20:49:00 UTC

[jira] [Updated] (LOG4J2-2373) StringBuilder escapeJson performs unnecessary Memory Allocations

     [ https://issues.apache.org/jira/browse/LOG4J2-2373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Andrew Meurer updated LOG4J2-2373:
----------------------------------------
    Description: 
The `StringBuilders.escapeJson` function currently uses the string builder's `insert` method to add elements to an existing builder for the purposes of escaping special characters.  Unfortunately, this leads to a regular expansion of the builder capacity, causing issues at scale.

A better approach would do a first run through to compute the total space required for the addition and then fill that space using the current method.

  was:
The StringBuilderUtils.escapeJson function currently uses the string builder's `insert` method to add elements to an existing builder for the purposes of escaping special characters.  Unfortunately, this leads to a regular expansion of the builder capacity, causing issues at scale.

A better approach would do a first run through to compute the total space required for the addition and then fill that space using the current method.


> StringBuilder escapeJson performs unnecessary Memory Allocations
> ----------------------------------------------------------------
>
>                 Key: LOG4J2-2373
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2373
>             Project: Log4j 2
>          Issue Type: Bug
>            Reporter: Kevin Andrew Meurer
>            Priority: Major
>
> The `StringBuilders.escapeJson` function currently uses the string builder's `insert` method to add elements to an existing builder for the purposes of escaping special characters.  Unfortunately, this leads to a regular expansion of the builder capacity, causing issues at scale.
> A better approach would do a first run through to compute the total space required for the addition and then fill that space using the current method.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)