Hi All,

I always get a OutOfMemoryError when I try to log a 10mb logmessage, even if I 
start the VM with the parameter "-Xmx80M" (heap-size for VM). I played around 
with settings and debuged the application. Log4j seems to duplicate the 10mb-
logmessage many times before it really logs.

Question: How much memory does Log4j need to log a 10mb log? How can I reduce 
the amount of memory needed? Which component needs the memory? Appender? 
Layout? Logger?

My Code:
public class MemoryTestLogger {

    private static final int MAX_SIZE = 10000000;
    private static Logger log = Logger.getLogger("test");

    public static void main(String[] args) {

        PropertyConfigurator.configure("test.properties");
        System.out.println("size: " + MAX_SIZE);
        //char[] chars = new char[MAX_SIZE];
        //String s = new String(chars);
        log.info(new String(new char[MAX_SIZE]));
    }
}

My Config: (test.properties)
log4j.appender.testApp = org.apache.log4j.FileAppender
log4j.appender.testApp.File = testlog
log4j.appender.testApp.ImmediateFlush = true
log4j.appender.testApp.Append = false
log4j.appender.testApp.layout = org.apache.log4j.PatternLayout
log4j.appender.testApp.layout.ConversionPattern = %m%n

log4j.logger.test = debug, testApp


Thanks for your help/ideas!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to