Link to home
Start Free TrialLog in
Avatar of danielj040300
danielj040300

asked on

MSXML IXMLHTTPRequest Memory Leak

I use the following code repeatedly to get responses from a server but the object leaks memory a lot. Does anybody have a clue why and how to fix it?

Daniel.


CComPtr<IXMLHTTPRequest> xml_Request;
HRESULT hr = xml_Request.CoCreateInstance( L"Msxml2.XMLHTTP.3.0", NULL, CLSCTX_INPROC_SERVER  );
if( hr != S_OK )
{
     AfxMessageBox("Could not create the XMLDOMHttpRequest object");
     return;
}

hr = xml_Request->open( L"POST", _bstr_t( (LPCTSTR)strUrl.c_str() ), _variant_t(false),
_variant_t(""), _variant_t(""));
if(hr != S_OK)
{
      AfxMessageBox("Error open connnection");
     return;
}

hr = xml_Request->send(vOpt);
if(hr != S_OK)
{
     AfxMessageBox("Error posting");
     return;
}
Avatar of jkr
jkr
Flag of Germany image

>>Does anybody have a clue why and how to fix it?

How do you use 'vOpt'?
Avatar of MattC
MattC

listening.....
Avatar of danielj040300

ASKER

Sorry Left that one out.
It is declared as follow:
_variant_t vOpt("");

Thanks.
Daniel.
ASKER CERTIFIED SOLUTION
Avatar of MattC
MattC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tries it using the whole block and only from "xml_Request->open()" but no luck. The memory leak only occurs after the 30th or so loop.

CComPtr do call the Release() method after it goes out of scope.

Thanks.
Daniel.
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days.

I am not sure what to suggest here. Could somebody please shed some light on the value of this thread ... otherwise it was suggested to delete and refund.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

Listening,
Computer101
E-E Moderator