D
David Lowndes
I'm seeing a memory leak (by watching the Private Bytes for the
process in PerfMon) in this simple C# application that calls a trivial
ATL COM object method when the COM method returns an error result.
Here's the C# code (console application):
[MTAThread]
static void Main(string[] args)
{
DLTestObjLib.DLTestObj1Class dlt1 = new
DLTestObjLib.DLTestObj1Class();
for ( int indx = 0; indx < 10000000; ++indx )
{
try
{
dlt1.T2();
}
catch
{
indx = indx;
}
}
}
and the method for the ATL COM object method:
STDMETHODIMP CDLTestObj1::T2(void)
{
HRESULT hRes;
hRes = E_FAIL;
AtlReportError( CLSID_DLTestObj1, "My error message",
IID_IDLTestObj1, hRes );
return hRes;
}
If I either:
1. Change:
hRes = E_FAIL;
to
hRes = S_OK;
or:
2. Comment out the AtlReportError line
.... the memory leak disappears!
Calling the COM object from a native C++ application doesn't show a
memory leak at all.
What's giving rise to the memory leak in the C# application? Am I
missing doing something?
Dave Lowndes
process in PerfMon) in this simple C# application that calls a trivial
ATL COM object method when the COM method returns an error result.
Here's the C# code (console application):
[MTAThread]
static void Main(string[] args)
{
DLTestObjLib.DLTestObj1Class dlt1 = new
DLTestObjLib.DLTestObj1Class();
for ( int indx = 0; indx < 10000000; ++indx )
{
try
{
dlt1.T2();
}
catch
{
indx = indx;
}
}
}
and the method for the ATL COM object method:
STDMETHODIMP CDLTestObj1::T2(void)
{
HRESULT hRes;
hRes = E_FAIL;
AtlReportError( CLSID_DLTestObj1, "My error message",
IID_IDLTestObj1, hRes );
return hRes;
}
If I either:
1. Change:
hRes = E_FAIL;
to
hRes = S_OK;
or:
2. Comment out the AtlReportError line
.... the memory leak disappears!
Calling the COM object from a native C++ application doesn't show a
memory leak at all.
What's giving rise to the memory leak in the C# application? Am I
missing doing something?
Dave Lowndes