You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Dominik Psenner (JIRA)" <ji...@apache.org> on 2013/06/06 10:05:21 UTC

[jira] [Resolved] (LOG4NET-198) Memory leak on a very basic code

     [ https://issues.apache.org/jira/browse/LOG4NET-198?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dominik Psenner resolved LOG4NET-198.
-------------------------------------

       Resolution: Invalid
    Fix Version/s:     (was: 1.2 Maintenance Release)

If a call to GC.Collect() is able to "solve" the memory leak, there is no memory leak at all. GC.Collect() gives the garbage collector just poke to wake up earlier than he would do by himself.
                
> Memory leak on a very basic code
> --------------------------------
>
>                 Key: LOG4NET-198
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-198
>             Project: Log4net
>          Issue Type: Test
>          Components: Core
>    Affects Versions: 1.2.10
>         Environment: windows xp sp3
>            Reporter: rauzy
>         Attachments: WindowsFormsApplication1.zip
>
>
> I build a simple form with a single button that start a timer execute every second, the task of this timer is to execute the following line:
> log.Debug("Hello");
> and I observe a memory leak.
> See Below.
> using System;
> using System.Collections.Generic;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Text;
> using System.Windows.Forms;
> using log4net;
> using log4net.Config;
> namespace WindowsFormsApplication1
> {
>     public partial class Form1 : Form
>     {
>         private static readonly ILog log = LogManager.GetLogger(typeof(Form1));
>         public Form1()
>         {
>             InitializeComponent();
>         }
>         private void button1_Click(object sender, EventArgs e)
>         {
>             XmlConfigurator.Configure();
>             FreqTimers.Start();
>         }
>         private void FreqTimers_Tick(object sender, EventArgs e)
>         {
>             log.Debug("demo");
>         }
>     }
> }
> with an app.config like 
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>   <configSections>
>     <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
>   </configSections>
>   <log4net debug="true">
>     <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
>       <file value="C:\\Temp\\TestMailer.log" />
>       <appendToFile value="true" />
>       <rollingStyle value="Size" />
>       <maxSizeRollBackups value="10" />
>       <maximumFileSize value="10MB" />
>       <staticLogFileName value="true" />
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%-5p %d - %m  %-18.18M %n" />
>       </layout>
>     </appender>
>     <root>
>       <level value="DEBUG" />
>       <appender-ref ref="RollingLogFileAppender" />
>     </root>
>   </log4net>
> </configuration>
> If you monitor the application, you see that the memory usage increase. Why? I can post the source solution if needed.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira