Log4net
  1. Log4net
  2. LOG4NET-192

Memory leaks with large multi-threaded application in log4net DLL 1.2.0.30714

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows 2003, .NET framework 1.1

      Description

      We've coded log4net (1.2.0-beta8) into our application. With log4net enabled we see our virtual memory increasing and never decreasing, over a period of time and particularly with stress testing the server runs out of memory and everything grinds to a halt.

        Activity

        Hide
        Ron Grabowski added a comment -

        You going to have to give us a little more information. Have you considered upgrading to the latest version of log4net? I know that log4net doesn't release often by 1.2.0-beta8 was released in 2003. That would make it about 6 years old.

        Show
        Ron Grabowski added a comment - You going to have to give us a little more information. Have you considered upgrading to the latest version of log4net? I know that log4net doesn't release often by 1.2.0-beta8 was released in 2003. That would make it about 6 years old.
        Hide
        Vibha Kapur added a comment -

        We have not tried latest version of log4net yet.
        But is it a bug in existing log4net DLL 1.2.0.30714 and upgrading to new log4net version 1.2.10 is the only solution?
        Also what would be the recommended logging level configuration (Error, fatal or info)?

        Show
        Vibha Kapur added a comment - We have not tried latest version of log4net yet. But is it a bug in existing log4net DLL 1.2.0.30714 and upgrading to new log4net version 1.2.10 is the only solution? Also what would be the recommended logging level configuration (Error, fatal or info)?
        Hide
        Vibha Kapur added a comment -

        Today we tried with new Log4Net also. It's again crashing when i set my log level to Debug.
        With Old Log4Net my applicaton is not crashing with log level Info.
        Please advice.

        Show
        Vibha Kapur added a comment - Today we tried with new Log4Net also. It's again crashing when i set my log level to Debug. With Old Log4Net my applicaton is not crashing with log level Info. Please advice.
        Hide
        Ron Grabowski added a comment -

        What is the exception? If you want help you need to show a stack trace, explain your configuration (post your log4net.config file), show how you're initializing log4net, how its being used, etc.

        Show
        Ron Grabowski added a comment - What is the exception? If you want help you need to show a stack trace, explain your configuration (post your log4net.config file), show how you're initializing log4net, how its being used, etc.
        Hide
        Vibha Kapur added a comment -

        We get following exception in our application log file:
        Caught Exception: [Exception of type System.OutOfMemoryException was thrown.] for Type [System.String]
        Exception: System.OutOfMemoryException
        Message: Exception of type System.OutOfMemoryException was thrown.

        We have given following log4net configuration in our application config file:
        <LogAndTrace>
        <Log4Net>
        <LoggerDefinition FileName="StrideSmartRouterAppLogs.config" FilePath="C:\Program Files\Elind\Stride\FIXGateway\SRBinaries" Severity="Debug" />
        </Log4Net>
        </LogAndTrace>

        We used to windbg tool to analyse the issue. We could see lot of log4net objects into wait state via SYNCBLKALL command. Here are top 15 rows:
        Index SyncBlock MonitorHeld Recursion Thread ThreadID Object Waiting
        1 0x00000000 0x01093178
        2 0x001967e4 0 0 0 none 0x01099c14 System.ServiceProcess.NativeMethods/ServiceMainCallback
        3 0x00196810 0 0 0 none 0x01099c4c System.ServiceProcess.NativeMethods/ServiceControlCallbackEx
        4 0x07eaf5b4 0 0 0 none 0x011383f8 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl
        5 0x00000000 0x0112f4dc
        6 0x00000000 0x01130a48
        7 0x001968c0 0 0 0 none 0x01132fa4 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl
        8 0x00196894 0 0 0 none 0x0113518c log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl
        9 0x07d71bb8 0 0 0 none 0x01138460 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl
        10 0x03df9770 0 0 0 none 0x011384c4 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl
        11 0x00000000 0x01365614
        12 0x00000000 0x01a160f8
        13 0x07de5d30 0 0 0 none 22501 Free
        14 0x1069bdbc 0 0 0 none 492 Free
        15 0x00000000 0x015096a4

        I analysed stack trace also at some basic level but did not get much info out of that.
        I am mailing my applicatin's Dumpstack at the yahoo ID mentioned in your profile.

        Show
        Vibha Kapur added a comment - We get following exception in our application log file: Caught Exception: [Exception of type System.OutOfMemoryException was thrown.] for Type [System.String] Exception: System.OutOfMemoryException Message: Exception of type System.OutOfMemoryException was thrown. We have given following log4net configuration in our application config file: <LogAndTrace> <Log4Net> <LoggerDefinition FileName="StrideSmartRouterAppLogs.config" FilePath="C:\Program Files\Elind\Stride\FIXGateway\SRBinaries" Severity="Debug" /> </Log4Net> </LogAndTrace> We used to windbg tool to analyse the issue. We could see lot of log4net objects into wait state via SYNCBLKALL command. Here are top 15 rows: Index SyncBlock MonitorHeld Recursion Thread ThreadID Object Waiting 1 0x00000000 0x01093178 2 0x001967e4 0 0 0 none 0x01099c14 System.ServiceProcess.NativeMethods/ServiceMainCallback 3 0x00196810 0 0 0 none 0x01099c4c System.ServiceProcess.NativeMethods/ServiceControlCallbackEx 4 0x07eaf5b4 0 0 0 none 0x011383f8 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl 5 0x00000000 0x0112f4dc 6 0x00000000 0x01130a48 7 0x001968c0 0 0 0 none 0x01132fa4 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl 8 0x00196894 0 0 0 none 0x0113518c log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl 9 0x07d71bb8 0 0 0 none 0x01138460 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl 10 0x03df9770 0 0 0 none 0x011384c4 log4net.Repository.Hierarchy.DefaultLoggerFactory/LoggerImpl 11 0x00000000 0x01365614 12 0x00000000 0x01a160f8 13 0x07de5d30 0 0 0 none 22501 Free 14 0x1069bdbc 0 0 0 none 492 Free 15 0x00000000 0x015096a4 I analysed stack trace also at some basic level but did not get much info out of that. I am mailing my applicatin's Dumpstack at the yahoo ID mentioned in your profile.
        Hide
        Ron Grabowski added a comment -

        By more information I meant things like posting your log4net.config file, not your configuration file to your application. What appenders are you using? FileAppender, MemoryAppender, etc.?

        <log4net>
        <appender name="FileAppender" type="log4net.Appender.FileAppender">
        </appender>
        <logger name="NHibernate" additivity="false">
        <level value="WARN" />
        <appender-ref ref="FileAppender" />
        </logger>
        </log4net>

        How are you configuring log4net?

        XmlConfigurator.ConfigureAndWatch(
        new FileInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "log4net.config"));

        Are you sure you're calling that configuring code just one time and not over and over?

        What kind of multi-threading are you using? Are you creating 1,000 background threads to do some of long running processing? What are all these threads doing? Are you trying to create a single massive log message and log that?

        Do you have a normal .NET stack trace showing where the out of memory exception came from? i.e. what method in log4net caused that exception?

        Is this your first time using log4net? Did you recently add log4net to your application?

        Show
        Ron Grabowski added a comment - By more information I meant things like posting your log4net.config file, not your configuration file to your application. What appenders are you using? FileAppender, MemoryAppender, etc.? <log4net> <appender name="FileAppender" type="log4net.Appender.FileAppender"> </appender> <logger name="NHibernate" additivity="false"> <level value="WARN" /> <appender-ref ref="FileAppender" /> </logger> </log4net> How are you configuring log4net? XmlConfigurator.ConfigureAndWatch( new FileInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "log4net.config")); Are you sure you're calling that configuring code just one time and not over and over? What kind of multi-threading are you using? Are you creating 1,000 background threads to do some of long running processing? What are all these threads doing? Are you trying to create a single massive log message and log that? Do you have a normal .NET stack trace showing where the out of memory exception came from? i.e. what method in log4net caused that exception? Is this your first time using log4net? Did you recently add log4net to your application?
        Hide
        Ron Grabowski added a comment -

        There hasn't been any additional posts on this item for several months after I asked for more information.

        Show
        Ron Grabowski added a comment - There hasn't been any additional posts on this item for several months after I asked for more information.

          People

          • Assignee:
            Unassigned
            Reporter:
            Vibha Kapur
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development