I notice a large leak in my program when using MSXML CoCreateInstance. I do not see memory being released after the CoUninitialize() is called. What should I do to make sure that memory gets released?
The below one is sample code,
void main()
{
printf("First Dump\n");
_getch();
unsigned int nCount = 4294967295;
{
for(int i = 0 ; i < nCount ; i++)
{
CComPtr <IXMLDOMDocument> pDOMdoc;
HRESULT hr = CoInitialize(NULL);
hr = pDOMdoc.CoCreateInstance(CLSID_DOMDocument60, 0, CLSCTX_INPROC_SERVER);
if(SUCCEEDED(hr))
{
printf("Succeded\n");
}
pDOMdoc = NULL;
CoUninitialize();
}
}
printf("Second Dump\n");
getch();
}
When I see in Task Manager, Memory(Private working set) has increased lot, I have taken the first snapshot at the beginning of the program,
Memory
Handles
Threads
Paged Pool
NP Pool
2360k
22
1
79k
4k
After running 8 hour duration, if I see task manager,
Memory
Handles
Threads
Paged Pool
NP Pool
19432k
40
1
88k
7k
I have taken the windbg dump, the dump shows our module in the call stack.
I have taken UMDH logs, it shows our module in the call stack.
According to me I have cleaned up the memory and called CoUninitialize(), which nothing but we should not have leaks. each run if there is no leaks then memory should not grow.
Why leaks are reported by UMDH, Windbg dump ? why Memory is not cleaned up after Second Snapshot? Any help is appreciated.
Regards
Sharan
The below one is sample code,
void main()
{
printf("First Dump\n");
_getch();
unsigned int nCount = 4294967295;
{
for(int i = 0 ; i < nCount ; i++)
{
CComPtr <IXMLDOMDocument> pDOMdoc;
HRESULT hr = CoInitialize(NULL);
hr = pDOMdoc.CoCreateInstance(CLSID_DOMDocument60, 0, CLSCTX_INPROC_SERVER);
if(SUCCEEDED(hr))
{
printf("Succeded\n");
}
pDOMdoc = NULL;
CoUninitialize();
}
}
printf("Second Dump\n");
getch();
}
When I see in Task Manager, Memory(Private working set) has increased lot, I have taken the first snapshot at the beginning of the program,
Memory
Handles
Threads
Paged Pool
NP Pool
2360k
22
1
79k
4k
After running 8 hour duration, if I see task manager,
Memory
Handles
Threads
Paged Pool
NP Pool
19432k
40
1
88k
7k
I have taken the windbg dump, the dump shows our module in the call stack.
I have taken UMDH logs, it shows our module in the call stack.
According to me I have cleaned up the memory and called CoUninitialize(), which nothing but we should not have leaks. each run if there is no leaks then memory should not grow.
Why leaks are reported by UMDH, Windbg dump ? why Memory is not cleaned up after Second Snapshot? Any help is appreciated.
Regards
Sharan