logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49899] New: PatternLayout and EnhancedPatternLayout issues with large messages
Date Wed, 08 Sep 2010 15:30:36 GMT

           Summary: PatternLayout and EnhancedPatternLayout issues with
                    large messages
           Product: Log4j
           Version: 1.2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Layout
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: sreich@mac.com

Created an attachment (id=26004)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26004)

When logging large messages (SOAP messages in my case), the two Layout classes
show up as a key contributor to memory pressure. Given a log entry size of say
1 megabyte, EnhancedPatternLayout.format will resize the StringBuffer from 16
to 33, 67, 135, ... creating a lot of unnecessary garbage along the way.
Even worse, PatternLayout holds on to that StringBuffer in a field, and doesn't
allow the its contents to be gc'ed until the next invocation.

Proposed fix. 
* If the message argument is a String, use its length to preallocate the
StringBuffer to reduce the chance of resizing.
* For PatternLayout, get rid of the StringBuffer field and allocate a new one
each time, which is what EnhancedPatternLayout.format does, too

Patch attached

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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

View raw message