log4net memory leak?

Memory profiling for .NET developers

Moderators: Luke Jefferson, StephenC, AndrewH, melvyn.harbour, james.billings, Laura Morley, dene.boulton

log4net memory leak?

Postby purplesoup » Mon Sep 24, 2012 11:02 am

We have an ASP.NET website where the memory isn't getting released.

I've been looking at my ANTS profiler information and seen calls from System.Web.NativeFileChangeNotification and also System.Threading.TimerCallback.

Searching on TimerCallback in our code comes up with a log4net file DOMConfigurator with the code below. Has anyone had any problems with log4net not releasing memory?


internal ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
{
m_repository = repository;
m_configFile = configFile;

// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();

watcher.Path = m_configFile.DirectoryName;
watcher.Filter = m_configFile.Name;

// Set the notification filters
watcher.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;

// Add event handlers. OnChanged will do for all event handlers that fire a FileSystemEventArgs
watcher.Changed += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
watcher.Created += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
watcher.Deleted += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
watcher.Renamed += new RenamedEventHandler(ConfigureAndWatchHandler_OnRenamed);

// Begin watching.
watcher.EnableRaisingEvents = true;

// Create the timer that will be used to deliver events. Set as disabled
m_timer = new Timer(new TimerCallback(OnWhatchedFileChange), null, Timeout.Infinite, Timeout.Infinite);
}
purplesoup
 
Posts: 2
Joined: Mon Sep 24, 2012 10:53 am

Postby Chris.Allen » Wed Dec 12, 2012 3:51 pm

The memory profiler should be able to tell you which objects are in memory and why- can you take several snapshots and try to identify objects that should not still be in memory? If log4net classes are leaking memory- this will show up well in the results which you can always send to us in support@red-gate.com
Chris.Allen
 
Posts: 594
Joined: Thu Mar 12, 2009 4:17 pm


Return to ANTS Memory Profiler 7

Who is online

Users browsing this forum: No registered users and 0 guests