"Chris Botha" <chris_s_botha@AT_h.o.t.m.a.i.l.com> wrote in message news:<OK**************@TK2MSFTNGP09.phx.gbl>...
I have a Windows app (it will be promoted to a Service once this problem is
sorted out) that cyclically, every minute, connects to five SQL Servers over
the WAN, extract data and insert the data in a local SQL Server, using the
OLEDB provider. Every cycle I create one local connection and five remote
connections, do the stuff, close the connections and dispose everything that
has a Dispose method (OleDbConnection, OleDbDataAdapter and OleDbCommand).
After running overnight the performance degrades and if I examine the
Private Bytes of the process (using Performance Monitor, the way we looked
for memory leaks before DOTNET in C++, but should still be valid), it goes
up from approx. 1.3 MB to over 2 MB.
I've been using DOTNET from the first Beta and never thought I'd say this,
but I suspect a leak.
Is there a method/tool that will show me the type of DOTNET objects being
leaked, or give me some indication of where to look for the problem?
Thanks.
This is how we do it. We had code that called a dll written in native
code. We were able to map out the memory leak pretty quickly.
-a
using System;
using System.Runtime.InteropServices;
using System.IO;
namespace MemoryCheck
{
public class Memory
{
public Memory()
{
}
private struct MEMORYSTATUS
{
public Int32 dwLength;
public Int32 dwMemoryLoad;
public Int32 dwTotalPhys;
public Int32 dwAvailPhys;
public Int32 dwTotalPageFile;
public Int32 dwAvailPageFile;
public Int32 dwTotalVirtual;
public Int32 dwAvailVirtual;
}
[DllImportAttribute("coredll.dll")]
private static extern void GlobalMemoryStatus(ref MEMORYSTATUS lp);
private static string getMemInfo()
{
MEMORYSTATUS ms=new MEMORYSTATUS();
GlobalMemoryStatus(ref ms);
return "\r\n" + DateTime.Now.ToString() +
"," + "dwMemoryLoad:" +
"," + ms.dwMemoryLoad +
"," + "dwTotalPhys:" +
"," + ms.dwTotalPhys+
"," + "dwAvailPhys:" +
"," + ms.dwAvailPhys +
"," + "dwTotalVirtual:" +
"," + ms.dwTotalVirtual +
"," + "dwAvailVirtual:" +
"," + ms.dwAvailVirtual + "\r\n";
}
public static void WriteMemory()
{
System.IO.StreamWriter sr = new StreamWriter(@"\test.txt", true);
sr.WriteLine(getMemInfo());
sr.Close();
return;
}
}
}