|
-
May 19th, 1999, 01:26 PM
#1
Reference Count
Is there some way to get the reference count for a COM object? I have a Release() that fails with an exception. It would be nice to inspect the reference count to see if someone has already released it.
-
May 20th, 1999, 05:03 PM
#2
Re: Reference Count
No cast iron way of knowing this.
The Release method returns a long (or a ULONG) which often is the number of references left on an object. If you're programming the server side, this may be sufficient.
We've had major fun with this issue on our project and not found tools such as Bounds Checker much of a help, so we came up with one solution (which really slows down execution time) which is to write every addref and release through a named pipe into a bit of code holding the number of references. This is a reasonable attempt and has helped to a point.
Another simple trick we use is to wrap the Release call in a macro COM_RELEASE(pObject) which sets pObject to null immediately and prevents accidental releasing of the object twice by the same function/class.
What I'd suggest is compile and test often and beware of the many smart pointer operations.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|