log4j memory use



I've been looking further into the memory use. It seems a lot of garbage
that is created is related to the logging. I found some references to
log4j sometimes creating a log of transient memory objects in
general[1]. However, I think i have found one specific thing in our
setup that makes it especially bad. This is our logging format:

log4j.appender.stdout.layout.ConversionPattern=%x %d{ABSOLUTE} %5p %c{1}:%L - %m%n

This is what the manual[2] has to say about %L:

L  Used to output the line number from where the logging request
   was issued.

   WARNING Generating caller location information is
   extremely slow. It's use should be avoided unless execution speed
   is not an issue.

And not only is the code slow, it also creates a lot of transient string
objects. What it does is create an exception object, calls
printStackTrace() on it and parses the string, extracting location
information from it. 

Maybe we should drop the %L from the log spec?

[1] http://mail-archives.apache.org/mod_mbox/logging-log4j-dev/200210.mbox/%3cOFE4B52E3C A49A64B9-ON86256C46 007182DC-86256C47 00564F6D perficient com%3e

[2] http://www.devdaily.com/java/jwarehouse/jakarta-log4j-1.2.8/src/java/org/apache/log4j/PatternLayout.shtml

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a genetically engineered day-dreaming photographer looking for 'the Big 
One.' She's a sharp-shooting junkie doctor from a different time and place. 
They fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]