?
Solved

com pointers - check ref count

Posted on 2005-03-06
5
Medium Priority
?
424 Views
Last Modified: 2013-11-25
With com pointer one should match calls that increment the ref count with an equal number to decrement the ref count.  Is there a tool/setting that one can use to check that the app is actually doing that correctly?
0
Comment
Question by:AndyAinscow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Accepted Solution

by:
nonubik earned 1500 total points
ID: 13474742
For a tool, you can use BoundsChecker http://www.compuware.com/products/devpartner/bounds.htm
0
 
LVL 5

Expert Comment

by:Greybird
ID: 13475128
Or you could use the return values of AddRef and Release.
0
 
LVL 22

Expert Comment

by:grg99
ID: 13475875
Ah, in general, no.

     An app could keep a pointer, or copy it to another variable, and "forget" to increment the reference count.  Or it could exit a block of code and forget to decrement it.

There are tools to peek at the reference count at any time, but that just tells you what the current count is, not where the app went wrong in counting up or down.

0
 
LVL 8

Expert Comment

by:novitiate
ID: 13476707
ATL smart pointers are the best way to handle reference count. As such I have not seen any tool doing this.

_COM_SMARTPTR_TYPEDEF(IMyInterface, __uuidof(IMyInterface));

will create a IMyInterfacePtr, smart pointer for you.

_novi_
0
 
LVL 30

Expert Comment

by:Axter
ID: 13477509
I recommend using CComQIPtr, which encapsulates the call to AddRef and Release calls.

When the CComQIPtr object goes out of scope, it calls Release automatically.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

801 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