Solved

MSXML IXMLHTTPRequest Memory Leak

Posted on 2001-07-16
7
559 Views
Last Modified: 2008-02-26
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;
}
0
Comment
Question by:danielj040300
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6286326
>>Does anybody have a clue why and how to fix it?

How do you use 'vOpt'?
0
 
LVL 1

Expert Comment

by:MattC
ID: 6286428
listening.....
0
 
LVL 1

Author Comment

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

Thanks.
Daniel.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Accepted Solution

by:
MattC earned 200 total points
ID: 6289144
are you re-using the same "xml_request" object each time or do you re-instatiate it, without killing the old object?
0
 
LVL 1

Author Comment

by:danielj040300
ID: 6289178
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.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6846113
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

0
 
LVL 1

Expert Comment

by:Computer101
ID: 6846131
Listening,
Computer101
E-E Moderator
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now