Yeah, I was thinking the same thing.  I'm not familiar with the memory 
appender, but by the name of it I would expect the memory consumption to go up 
each time you log an event.

Thanks,
Nick

From: a...@recombulator.net
To: log4net-user@logging.apache.org; e...@flex-radio.com
Date: Mon, 19 Oct 2015 15:28:57 -0400
Subject: Re: log4net Memory Leak








Ummm... You are using a memory
appender. 


On
October 19, 2015 2:53:20 PM Eric Wachsmann <e...@flex-radio.com>
wrote:

While I am sure that it is a
result of misconfiguration, I have a memory leak issue while using log4net
that I wondered if someone here could help me resolve.  We are using
log4net to log serial data in our application to a file.  Because the calls
for the serial port always come from the same class, we are less interested
in the class/function and more interested in which COM port sent/received
the data and what was in the data.  As such, we pass one logger object
around to be used by multiple serial port.
Running
Regate ANTS memory profiler, it finds that the memory is piling up in the
form of strings that aren't released after calling the log4net Debug
function.  If I comment the 2 calls to logger.Debug, the memory becomes
stable in the same environment.  Can someone help me figure out what
I'm doing wrong here?  Below is our config setup.  Thanks.

Eric
Wachsmann

==================private ILog logger;
private void LoggerSetup()       
{            logger =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 
          Hierarchy hierarchy =
(Hierarchy)LogManager.GetRepository();               
        PatternLayout patternLayout = new PatternLayout();     
      //patternLayout.ConversionPattern = "%date [%thread] %-5level
%logger - %message%newline";           
patternLayout.ConversionPattern = "%date{yyyy-MM-dd HH:mm:ss}
%message%newline";                       
patternLayout.ActivateOptions();
           
RollingFileAppender roller = new RollingFileAppender();         
  roller.AppendToFile = true;            roller.File =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
@"[company\LogFiles\[application].log");           
roller.Layout = patternLayout;           
roller.MaxSizeRollBackups = 5;            roller.MaximumFileSize
= "5MB";            roller.RollingStyle =
RollingFileAppender.RollingMode.Size;           
roller.StaticLogFileName = true;           
roller.ActivateOptions();           
hierarchy.Root.AddAppender(roller);
           
MemoryAppender memory = new MemoryAppender();           
memory.ActivateOptions();           
hierarchy.Root.AddAppender(memory);
           
hierarchy.Root.Level = Level.All;           
hierarchy.Configured = true;        }



                                          

Reply via email to