Bear in mind that even if it has been garbage collected, the process won't 
release the memory unless the machine is under memory pressure - that means 
32Kb free ISTR!

Paul

----------------------------------------

From: "Peter Drier" <[EMAIL PROTECTED]>
Sent: 28 April 2008 17:18
To: "Log4NET User" <log4net-user@logging.apache.org>
Subject: Re: log4net Memory Leak 

Memory leaks in dotnet are often misunderstood.  from 5+ years of using 
log4net, I sincerely doubt that's where your problem originates..  

You're going to want to determine what (if anything) has a reference to the 
memory in question.  I'm not sure how easy that is to do in WinDBG, but 
Redgate's Ants is what we use and it works well.

Chances are either:
1.  The memory is no longer referenced, but has not been garbage collected as 
of yet.
2.  Some other part of your code is still referencing this memory, keeping it 
alive.

We had a problem a few years back where the Debug Processes() bit within dotnet 
had a confirmed (by Microsoft) leak..  but that was back in the 1.1 days..  

Cheers,
Peter

On Mon, Apr 28, 2008 at 11:52 AM, Jeff Patzner <[EMAIL PROTECTED]> wrote:

We are currently experiencing a reproducible memory leak in a C# .NET Web 
Service. When we analyze the memory using WinDBG, are are able to find loads 
and loads of strings containing the information that we are logging in our Web 
Service. So each time we write to the log, that string is stuck in the memory 
for our aspnet_wp process. We have verified this by dumping the actual string 
objects and finding the data that we logged. 

We have included below our configuration, our global.asax snippet, and also a 
snippet of our source code to demonstrate how we are utilizing log4net.

***Our configuration***

<log4net>

<appender name="AWD2FNLogger" 
type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="c:\\AWD2FNLog.log" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="20" />
<!-- uncomment to set maximum file size limit <param name="MaximumFileSize" 
value="100MB" />-->
<param name="RollingStyle" value="Date" />
<param name="StaticLogFileName" value="false" />
<param name="LockingModel" value="MinimalLock"/>
<param name="DatePattern" value="MM-dd-yyyy"/>

<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
</layout>

</appender>

<!-- Setup the root category, add the appenders and set the default priority -->

<root>
<priority value="DEBUG" />
<appender-ref ref="AWD2FNLogger" />
</root>

</log4net>

****Our Global.asax snippet*****

<%@ Application Language="C#" %>

<script runat="server">

void Application_Start(object sender, EventArgs e) 
{
// Code that runs on application startup
log4net.Config.XmlConfigurator.Configure();

}

****our code snippet******

using log4net;
using log4net.Config;

public class AWD2FN : System.Web.Services.WebService
{
private static readonly ILog mylog = 
LogManager.GetLogger("RollingLogFileAppender");
public AWD2FN () {
BasicConfigurator.Configure();
}
}

[WebMethod]
public FNReturn AddDocument(string FileLocation, FNProp[] Properties, string 
DocClass)
{

//create an instance of our helper class procs
Procs myProcs = new Procs();

//get the calling IP of the client so we can distinguish them
string strCallingIP;
strCallingIP = myReq.ServerVariables["REMOTE_ADDR"];

//and the logging begins
mylog.Info("Calling IP: " + strCallingIP + "; Entering AddDocument. 
FileLocation: " + FileLocation + ", DocClass: " + DocClass
+ ", Properties: \r\n" + myProcs.DumpProps(Properties).ToString() );

//create a FNReturn object and a FNETAdd object
//the constructor of the FNETAdd takes in all the parameters
//the doAdd function returns a FNReturn object
FNReturn fnrAdd;
FNETAdd objAdd;
fnrAdd = new FNReturn();
objAdd = new FNETAdd(DocClass, FileLocation, Properties, fnuAWD2FN);
fnrAdd = objAdd.DoAdd();

if (fnrAdd.Status == "Success")
{
//we have successfully added the document
mylog.Info("Calling IP: " + strCallingIP + "; Leaving AddDocument. Status: " + 
fnrAdd.Status + ", Value: " + fnrAdd.Value + " SessionID: " + fnrAdd.LogonID);
}
else
{
//adding of the document failed
mylog.Error("Calling IP: " + strCallingIP + "; Leaving AddDocument. Status: " + 
fnrAdd.Status + ", Value: " + fnrAdd.Value + " SessionID: " + fnrAdd.LogonID);
if (fnrAdd.LogonID != "")
{
//let's add this to the session management so this session can
//be removed with the logoffall function call
AddSession(fnuAWD2FN.superuser, fnrAdd.LogonID);
}

}

return fnrAdd;
} 

__________________________________________
The information contained in this message may be privileged and confidential 
and protected from disclosure. If you are not the intended recipient of this 
message, you are hereby notified that any dissemination, distribution, or 
copying of this communication is strictly prohibited. If you have received this 
communication in error, please notify us immediately by replying to the 
message, and please delete it from your computer.

-- 
Peter's Photography
www.PeterDrier.com

Reply via email to