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!

Detach() vs. Release()

Status
Not open for further replies.

Valius

Programmer
Oct 20, 2000
174
US
Dealing with COM objects, what's the difference between the Detach() and Release() functions...and if you don't release the pointer after using it, will it "eat up" memory resources after a while? I have a program that just freezes and stops responding after it sits for a while...could this be the problem? Thanks in advance for any comments!

Niky Williams
NTS Marketing
 
> Dealing with COM objects, what's the difference between the Detach() and Release()

IUnknown defines the following:
AddRef()
Release()
QueryInterface()

Detach() is specific to an interface or perhaps some class that encapsulates IUnkown ( There are many ).

So to know what the difference is you need to know what IUnknown::Release() does and what ?????::Detach() does.

IUnknown::Release() causes the reference count on that object to be decremented and IF the count reaches zero the object is destroyed.

The meaning of Detach() could be the same, however perhaps not. We must really read the documentation for the class that is implementing the Detach() function.

> could this be the problem?

Well it could be, but it could also be a hundered other things.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top