Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CoCreateInstance Handle Count

Status
Not open for further replies.

smpaul

Programmer
Nov 13, 2002
7
GB
Any help from any COM experts out there would be gratefully received.

I am debugging a server application which steadily increases the applications Handle Count at a rate that would cause problems for the server machine after approx 1 week.

One area which appears to be a problem is in a Class contructor which contains the following code:
CANCXMLBase::CANCXMLBase(CLogBase *pLogIn)
{
// ...

hr=CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&m_xml_doc);

// ...
}
Each time the object is instantiated it goes through the CoCreateInstance code and increments the handle count by 4.

The destructor is as follows:
CANCXMLBase::~CANCXMLBase()
{
if(m_xml_doc)
{
ReleaseIt(m_node_error);
m_xml_doc->Release();
m_xml_doc=NULL;
}
}

After the destructor call the handle count remains +4 and never seems to reduce.

Am I wrong in thinking that the m_xml_doc->Release() should release resources allocated in the CoCreateInstance call?

Incidentally I am viewing the handle count through Task Manager.

Thanks for reading.
 
If I use COM API I do usualy like this:
if(m_xml_doc)
{
if(m_xml_doc->AddRef() > 2)
{
m_xml_doc->Release();
m_xml_doc->Release();
}else
{
m_xml_doc->Release();
}
m_xml_doc=NULL;
}

in big applications ref count based pointers cause too many problems, so often because of unknown (or many of known) reasons COM do nothing when you call Release().

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top