livelazily / log4jdbc-log4j2

Automatically exported from code.google.com/p/log4jdbc-log4j2
0 stars 0 forks source link

OutOfMemoryError when large tables are logged #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load a big table with a lot of data
2. Log everything with slf4j (logback)
3. ResultSetCollectorPrinter will produce an OutOfMemoryError

What is the expected output? What do you see instead?
No error is expected

What version of the product are you using? On what operating system?
1.16

Please provide any additional information below.
If the Slf4jSpyDelegate would check in its resultSetCollected method if the 
info level is allowed, this would be no problem. The Slf4jSpyDelegate 
.resultSetCollected should look similar to this:

@Override
    public void resultSetCollected(ResultSetCollector resultSetCollector) {
        if (resultSetTableLogger.isInfoEnabled()) {
            String resultsToPrint = new ResultSetCollectorPrinter().getResultSetToPrint(resultSetCollector);    
            resultSetTableLogger.info(resultsToPrint);
        }
    }

Original issue reported on code.google.com by markus.v...@gmail.com on 27 Jan 2015 at 2:50

GoogleCodeExporter commented 9 years ago
Hi, 

I don't think this is related, could you please provide the stack trace?

(resutSetCollected is called by ResultSetSpy#reportAllReturns; it uses the 
ResultSetCollector only if not null; ResultSetCollector initialization is done 
in ResultSetSpy constructor; this constructor calls 
SpyLogDelegator#isResultSetCollectionEnabled() to check whether a 
ResultSetCollector should be used)

Original comment by frederic...@gmail.com on 31 Jan 2015 at 10:48

GoogleCodeExporter commented 9 years ago
Hi,

I don't get a stacktrace, just an OutOfMemoryError with a headdump. While 
analyzing the heapdump I noticed that there is a char[] that holds 114MB. This 
char array comes from the StringBuffer table you use in the 
ResultSetCollectorPrinter. This variable is only used in the 
getResultSetToPrint method which again is called by the 
Slf4jSpyLogDelegator#resultSetCollected method. This method creates the table 
and then loggs it to info so even if I set the log level for this logger to OFF 
the table would still be build which causes the OutOfMemoryError.

Original comment by markus.v...@gmail.com on 2 Feb 2015 at 8:02

GoogleCodeExporter commented 9 years ago
See my previous message: the ResultSetCollector is null when this logger is OFF 
(see constructor of ResultSetSpy), so this is unlikely to be the cause of your 
problem: the ResulSetCollectorPrinter will do nothing without a 
ResultSetCollector.

Could you please reproduce the steps that generated your errors, after making 
sure that the logger is off, and send me the stacktrace and logger 
configuration?

Thank you.

Original comment by frederic...@gmail.com on 2 Feb 2015 at 9:40

GoogleCodeExporter commented 9 years ago
Hi, thanks. Now I got it and could fix the problem. 

Original comment by markus.v...@gmail.com on 2 Feb 2015 at 2:11

GoogleCodeExporter commented 9 years ago
Glad you fixed it :)

Original comment by frederic...@gmail.com on 3 Feb 2015 at 12:34