You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by "P, Rajasekar" <Ra...@netapp.com> on 2021/12/09 14:21:01 UTC

RE: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0

Team,

We have recently upgraded log4net to 2.0.12.0
Post upgrade, we are seeing memory leak in our application.
When we did our analysis with the captured dump, found more log4net instances in the Gen2 (pls refer below screenshot for details).

Additional required information below,

log4net version - 2.0.12.0
assembly type - DLL
code is launched as an windows application.
Runt time platform - MS .NET


[cid:image001.png@01D7ED36.14794DF0]

[cid:image002.png@01D7ED36.14794DF0]

Can we get some help here ? or please help us with the right channel to raise a support ticket.

Thanks,
Raj.

Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0

Posted by Dominik Psenner <dp...@gmail.com>.
Hi Raj,

The usage I used so far is to create appenders only on application startup.
Your usage goes way beyond that. Without debugging I can't tell how it
would behave. From memory, I can recall that the logger hierarchy is
fundamentally a static variable. You may be able to improve your situation
by spawning and disposing of AppDomains. From your description I guess that
you could benefit from a dedicated AppDomain for each of your jobs or a
dedicated AppDomain for a batch of jobs. This for example ensures that a
failing job cannot take down other jobs.

See
https://docs.microsoft.com/en-us/dotnet/api/system.appdomain?view=net-6.0

Warm regards,
Dominik

On Thu, 13 Jan 2022 at 10:56, P, Rajasekar <Ra...@netapp.com> wrote:

> Thanks Dominik.
>
>
>
> I had gone through the code implementation and enabled the log4net
> internal debugging to understand the issue better.
>
> As per the implementation, we do have log file for each job – and based on
> the configuration we can have n number of jobs running on daily basis.
>
>
>
> For each job, we are creating new log instance and appender and on job
> completion we do call the close log method,
>
>
>
> *Close Log – Method Pseudocode for better understanding*
>
> 1)      CloseNestedAppenders()
>
> 2)      RemoveAllAppenders()
>
>
>
> 3)      Remove Appender from the root hierarchy if exists and then close
>
> 4)      Remove Appender from the Parent if exists and then close.
>
>
>
> Even after performing the above steps, we are seeing the appender
> instances alive in the dump.
>
> Please let me know if any further information required.
>
>
>
> Thanks,
>
> Raj.
>
>
>
> *From:* Dominik Psenner <dp...@gmail.com>
> *Sent:* 11 December 2021 14:21
> *To:* Log4NET User <lo...@logging.apache.org>
> *Cc:* rongrabowski@yahoo.com; Bethur, Mohan <Mo...@netapp.com>; G,
> Mohankumar <Mo...@netapp.com>
> *Subject:* Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0
>
>
>
> *NetApp Security WARNING*: This is an external email. Do not click links
> or open attachments unless you recognize the sender and know the content is
> safe.
>
>
>
> Hi P. Rajasekar,
>
>
>
> in your screenshot I do see that there are more than 265k live instances
> of the RollingFileAppender. I recommend you investigate why there are so
> many instances of appenders.
>
>
>
> Warm regards,
>
> Dominik
>
>
>
> On Fri, 10 Dec 2021 at 05:36, P, Rajasekar <Ra...@netapp.com> wrote:
>
> Team,
>
>
>
> Please find the required info below,
>
>
>
> .Net Version - .Net Framework 4.5.2
>
>
>
> Log4net version upgraded from – 1.2.13
>
>
>
> Configuration details below,
>
>
>
> <loggingConfiguration name="" tracingEnabled="true" defaultCategory=
> "General"> <listeners> <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="SnapDrive For
> Windows" formatter="Text Formatter" log="" machineName="."
> traceOutputOptions="None" /> <add name="Rolling Flat File Trace Listener"
> type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName=
> "SnapDriveSALDebug.log" footer="" formatter="Text Formatter" header=""
> rollFileExistsBehavior="Increment" rollSizeKB="20480" traceOutputOptions="LogicalOperationStack,
> DateTime, Timestamp, ProcessId, ThreadId, Callstack" maxArchivedFiles="20"
> /> </listeners> <formatters> <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="{timestamp(local:o)}
> {severity} SAL PID=[{localProcessId}] TID=[{win32ThreadId}] {message}"
> name="Text Formatter" /> </formatters> <categorySources> <add switchValue=
> "All" name="EventLog"> <listeners> <add name="Event Log Listener" /> </
> listeners> </add> <add switchValue="All" name="General"> <listeners> <add
> name="Rolling Flat File Trace Listener" /> </listeners> </add> </
> categorySources> <specialSources> <allEvents switchValue="All" name="All
> Events" /> <notProcessed switchValue="All" name="Unprocessed Category" />
> <errors switchValue="All" name="Logging Errors &amp; Warnings"> <listeners
> > <add name="Rolling Flat File Trace Listener" /> </listeners> </errors>
> </specialSources> </loggingConfiguration>
>
> Thanks,
>
> Raj.
>
>
>
> *From:* Ron Grabowski <ro...@yahoo.com>
> *Sent:* 10 December 2021 03:08
> *To:* log4net-user@logging.apache.org
> *Subject:* Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0
>
>
>
> *NetApp Security WARNING*: This is an external email. Do not click links
> or open attachments unless you recognize the sender and know the content is
> safe.
>
>
>
> I don't spent a lot of time in the .NET space so I might not be able to
> help much. Can you share a snippet of your configuration file? What version
> did you upgrade from? What version and flavor of .NET are you using: Core
> vs Framework?
>
>
>
> On Thursday, December 9, 2021, 09:21:39 AM EST, P, Rajasekar <
> rajasekar.p@netapp.com> wrote:
>
>
>
>
>
> Team,
>
>
>
> We have recently upgraded log4net to 2.0.12.0
>
> Post upgrade, we are seeing memory leak in our application.
>
> When we did our analysis with the captured dump, found more log4net
> instances in the Gen2 (pls refer below screenshot for details).
>
>
>
> Additional required information below,
>
>
>
> log4net version - 2.0.12.0
> assembly type – DLL
> code is launched as an windows application.
> Runt time platform - MS .NET
>
>
>
>
>
>
>
>
>
> Can we get some help here ? or please help us with the right channel to
> raise a support ticket.
>
>
>
> Thanks,
>
> Raj.
>
>
>
>
> --
>
> Dominik Psenner
>


-- 
Dominik Psenner

RE: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0

Posted by "P, Rajasekar" <Ra...@netapp.com>.
Thanks Dominik.

I had gone through the code implementation and enabled the log4net internal debugging to understand the issue better.
As per the implementation, we do have log file for each job – and based on the configuration we can have n number of jobs running on daily basis.

For each job, we are creating new log instance and appender and on job completion we do call the close log method,

Close Log – Method Pseudocode for better understanding

1)      CloseNestedAppenders()

2)      RemoveAllAppenders()


3)      Remove Appender from the root hierarchy if exists and then close

4)      Remove Appender from the Parent if exists and then close.

Even after performing the above steps, we are seeing the appender instances alive in the dump.
Please let me know if any further information required.

Thanks,
Raj.

From: Dominik Psenner <dp...@gmail.com>
Sent: 11 December 2021 14:21
To: Log4NET User <lo...@logging.apache.org>
Cc: rongrabowski@yahoo.com; Bethur, Mohan <Mo...@netapp.com>; G, Mohankumar <Mo...@netapp.com>
Subject: Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0

NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.


Hi P. Rajasekar,

in your screenshot I do see that there are more than 265k live instances of the RollingFileAppender. I recommend you investigate why there are so many instances of appenders.

Warm regards,
Dominik

On Fri, 10 Dec 2021 at 05:36, P, Rajasekar <Ra...@netapp.com>> wrote:
Team,

Please find the required info below,

.Net Version - .Net Framework 4.5.2


Log4net version upgraded from – 1.2.13

Configuration details below,

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General"> <listeners> <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="SnapDrive For Windows" formatter="Text Formatter" log="" machineName="." traceOutputOptions="None" /> <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="SnapDriveSALDebug.log" footer="" formatter="Text Formatter" header="" rollFileExistsBehavior="Increment" rollSizeKB="20480" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" maxArchivedFiles="20" /> </listeners> <formatters> <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="{timestamp(local:o)} {severity} SAL PID=[{localProcessId}] TID=[{win32ThreadId}] {message}" name="Text Formatter" /> </formatters> <categorySources> <add switchValue="All" name="EventLog"> <listeners> <add name="Event Log Listener" /> </listeners> </add> <add switchValue="All" name="General"> <listeners> <add name="Rolling Flat File Trace Listener" /> </listeners> </add> </categorySources> <specialSources> <allEvents switchValue="All" name="All Events" /> <notProcessed switchValue="All" name="Unprocessed Category" /> <errors switchValue="All" name="Logging Errors &amp; Warnings"> <listeners> <add name="Rolling Flat File Trace Listener" /> </listeners> </errors> </specialSources> </loggingConfiguration>
Thanks,
Raj.

From: Ron Grabowski <ro...@yahoo.com>>
Sent: 10 December 2021 03:08
To: log4net-user@logging.apache.org<ma...@logging.apache.org>
Subject: Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0

NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.

I don't spent a lot of time in the .NET space so I might not be able to help much. Can you share a snippet of your configuration file? What version did you upgrade from? What version and flavor of .NET are you using: Core vs Framework?

On Thursday, December 9, 2021, 09:21:39 AM EST, P, Rajasekar <ra...@netapp.com>> wrote:



Team,



We have recently upgraded log4net to 2.0.12.0

Post upgrade, we are seeing memory leak in our application.

When we did our analysis with the captured dump, found more log4net instances in the Gen2 (pls refer below screenshot for details).



Additional required information below,



log4net version - 2.0.12.0
assembly type – DLL
code is launched as an windows application.
Runt time platform - MS .NET





[cid:image001.png@01D8088C.63F40610]



[cid:image002.png@01D8088C.63F40610]



Can we get some help here ? or please help us with the right channel to raise a support ticket.



Thanks,

Raj.


--
Dominik Psenner

Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0

Posted by Dominik Psenner <dp...@gmail.com>.
Hi P. Rajasekar,

in your screenshot I do see that there are more than 265k live instances of
the RollingFileAppender. I recommend you investigate why there are so many
instances of appenders.

Warm regards,
Dominik

On Fri, 10 Dec 2021 at 05:36, P, Rajasekar <Ra...@netapp.com> wrote:

> Team,
>
>
>
> Please find the required info below,
>
>
>
> .Net Version - .Net Framework 4.5.2
>
>
>
> Log4net version upgraded from – 1.2.13
>
>
>
> Configuration details below,
>
>
>
> <loggingConfiguration name="" tracingEnabled="true" defaultCategory=
> "General"> <listeners> <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="SnapDrive For
> Windows" formatter="Text Formatter" log="" machineName="."
> traceOutputOptions="None" /> <add name="Rolling Flat File Trace Listener"
> type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName=
> "SnapDriveSALDebug.log" footer="" formatter="Text Formatter" header=""
> rollFileExistsBehavior="Increment" rollSizeKB="20480" traceOutputOptions="LogicalOperationStack,
> DateTime, Timestamp, ProcessId, ThreadId, Callstack" maxArchivedFiles="20"
> /> </listeners> <formatters> <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="{timestamp(local:o)}
> {severity} SAL PID=[{localProcessId}] TID=[{win32ThreadId}] {message}"
> name="Text Formatter" /> </formatters> <categorySources> <add switchValue=
> "All" name="EventLog"> <listeners> <add name="Event Log Listener" /> </
> listeners> </add> <add switchValue="All" name="General"> <listeners> <add
> name="Rolling Flat File Trace Listener" /> </listeners> </add> </
> categorySources> <specialSources> <allEvents switchValue="All" name="All
> Events" /> <notProcessed switchValue="All" name="Unprocessed Category" />
> <errors switchValue="All" name="Logging Errors &amp; Warnings"> <listeners
> > <add name="Rolling Flat File Trace Listener" /> </listeners> </errors>
> </specialSources> </loggingConfiguration>
>
> Thanks,
>
> Raj.
>
>
>
> *From:* Ron Grabowski <ro...@yahoo.com>
> *Sent:* 10 December 2021 03:08
> *To:* log4net-user@logging.apache.org
> *Subject:* Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0
>
>
>
> *NetApp Security WARNING*: This is an external email. Do not click links
> or open attachments unless you recognize the sender and know the content is
> safe.
>
>
>
> I don't spent a lot of time in the .NET space so I might not be able to
> help much. Can you share a snippet of your configuration file? What version
> did you upgrade from? What version and flavor of .NET are you using: Core
> vs Framework?
>
>
>
> On Thursday, December 9, 2021, 09:21:39 AM EST, P, Rajasekar <
> rajasekar.p@netapp.com> wrote:
>
>
>
>
>
> Team,
>
>
>
> We have recently upgraded log4net to 2.0.12.0
>
> Post upgrade, we are seeing memory leak in our application.
>
> When we did our analysis with the captured dump, found more log4net
> instances in the Gen2 (pls refer below screenshot for details).
>
>
>
> Additional required information below,
>
>
>
> log4net version - 2.0.12.0
> assembly type – DLL
> code is launched as an windows application.
> Runt time platform - MS .NET
>
>
>
>
>
>
>
>
>
> Can we get some help here ? or please help us with the right channel to
> raise a support ticket.
>
>
>
> Thanks,
>
> Raj.
>


-- 
Dominik Psenner

Re: Log4Net - Memory Leak - Post Upgrade to version 2.0.12.0

Posted by Ron Grabowski <ro...@yahoo.com>.
 I don't spent a lot of time in the .NET space so I might not be able to help much. Can you share a snippet of your configuration file? What version did you upgrade from? What version and flavor of .NET are you using: Core vs Framework?
    On Thursday, December 9, 2021, 09:21:39 AM EST, P, Rajasekar <ra...@netapp.com> wrote:  
 
  
Team,
 
  
 
We have recently upgraded log4net to 2.0.12.0
 
Post upgrade, we are seeing memory leak in our application.
 
When we did our analysis with the captured dump, found more log4net instances in the Gen2 (pls refer below screenshot for details).
 
  
 
Additional required information below,
 
  
 
log4net version - 2.0.12.0
assembly type – DLL
code is launched as an windows application.
Runt time platform - MS .NET
 
  
 
  
 

 
  
 

 
  
 
Can we get some help here ? or please help us with the right channel to raise a support ticket.
 
  
 
Thanks,
 
Raj.