|
-
May 6th, 1999, 04:35 PM
#1
Memory Leak
I have an COM in-process DLL server (Debug Build) built using VC++ 6.0. When I use a VB client to instanciate, run and release via
1) Dim MyObject as xyz
2) Set MyObj=new xyz
3) Call some property or method
4) Set MyObj=nothing
VC++ does not detect any memory leaks.
When I instanciate and immediately release the object from a VC++ client via
1) CoCreateInstance()
2) AddRef()
3) Release()
and then the VC++ client exits, lots memory leaks are detected. Some seem to be CString objects (i.e., member variables - not pointers belonging to classes on the COM server) that do not get released, other allocation done by ATL.
Has anyone seen this before and have an idea as so what is going on. Also are there any tools for identifying the "real" leaks.
Thkx in advance for any help
-
May 7th, 1999, 09:50 AM
#2
Re: Memory Leak
You are missing a "Release()".
CoCreateInstance --> ref. count = 1
AddRef() --> ref. count = 2
Release() --> ref. count = 1
Since your object has a reference count of 1, it won't delete itself. So all you need is another Release().
FYI, CoCreateInstance does an AddRef() on IUnknown (or whatever interface you requested) automatically. Actually done inside your Class Factory's CreateInstance.
-Safai
-
May 7th, 1999, 11:36 AM
#3
Re: Memory Leak
Safai -
Thank you so very much. Of course I fogot one of the most basic tenents of COM 101, that CoCreateInstance does an AddRef. Having looked at this problem (on and off) over the past 6 months, your help ultimately solved it once and for all. Thank you for taking the time to answer my post.
Regards
Al Crown
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
|