AddRef() function increments the reference count of the object. Release() function decrements the reference count of the object and when the life time expires or rather the reference count reaches zero, server deallocates the object.
The IUnknown::AddRef method increments the reference count for an interface on an object.
It should be called for every new copy of a pointer to an interface on a given object.
Returns an integer from 1 to n, the value of the new reference count. This information is meant to be used for diagnostic/testing purposes only, because, in certain situations, the value may be unstable.
Objects use a reference counting mechanism to ensure that the lifetime of the object includes the lifetime of references to it.
Every COM object includes a 32 bit unsigned integer member variable for reference counting. Initial value of this reference count is zero.
IUnknown::AddRef is called to stabilize a copy of an interface pointer and increments it by one. The updated value is returned.
This is called by IUnknown::QueryInteface in server side and it can also be called when object is cloned as pointer.
Reference count can have values from 1 to (2^31)-1. Reference count increment should be atomic in case of objects are handled in multi-threaded apartment.
Decrements the reference count for the calling interface on a object. If the reference count on the object falls to 0, the object is freed from memory.
Returns the resulting value of the reference count, which is used for diagnostic/testing purposes only. If you need to know that resources have been freed, use an interface with higher-level semantics.
IUnknown::Release returns the current reference count and decrements the reference count of the object.
Reference count decrement should be atomic if client is accessing multi-threaded apartment model.
IUnknown::Release should be called by the client at the end when this object is no longer needed in the program.
COM server deletes or frees the memory allocated by the object once this is called.
Client should not call any interface function after this call.
You have viewed 1 page out of 66. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.
Similar topics related to this section
COM DCOM Interview Questions and Answers :: ALL Interview .com
COM DCOM - COM DCOM Interview Questions
COM interview questions | TechInterviews
COM Interview Questions - CodeProject
Com Dcom Interview Questions - Com and Dcom in Asp Net
ATL Interview Questions and Answers :: ALL Interview .com
ActiveX Interview Questions and Answers :: ALL Interview .com
| #1 webmaster Tue 29 Apr/2014 02:07:42(GMT) || 0 || 0|
We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.
Your message goes here: