https://issues.apache.org/bugzilla/show_bug.cgi?id=49899
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: [email protected]
ReportedBy: [email protected]
Created an attachment (id=26004)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=26004)
Patch
Issue
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: [email protected]
For additional commands, e-mail: [email protected]