ICollectionOnSTL / CComEnumOnSTL 
Author Message
 ICollectionOnSTL / CComEnumOnSTL

//////////////////////////////////
// DEDUG ROUTINES

 int  tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
 // Turn on leak-checking
  tmpFlag |=  _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF ;
  // Set flag to the new value
  _CrtSetDbgFlag( tmpFlag );

//END DEBUG ROUTINES
//////////////////////////////////

Use this code in your starting point (main .cpp, _tWinMain or DllMain).
when you end your program you will see memory leak report if there are some
leaks.
--
Michail
MCP,MCSD


Quote:
> Hi everyone,

> I've started to write an ICollectionOnSTL-based class for a thumbnail
> control that will be scripted against in Internet Explorer and I'm hoping
> that someone can check my use of CAdapt< CComPtr< > > in the
> ICollectionOnSTLImpl template and _Copy classes with special regards for
the
> reference counting of the contained CComPtr elements--The collection seems
> to work fine so far, but I'd like to make sure there are no memory leaks
> before going much further.. Thanks!

> Anthony Davis



Sun, 16 May 2004 18:58:31 GMT  
 ICollectionOnSTL / CComEnumOnSTL
Thanks, but how do I see the debug output from my DLL (I'm testing the
control in Internet Explorer/ActiveX Control Test Container)?  Also, isn't
it possible that COM memory leaks (from AddRef()s w/o matching Release()s)
will still not be detected this way?  Specifically, my collection class is
designed to hold smart pointers to externally created (in script) IThumb
objects which are AddRef'd when the collection is enumerated and I'm not
sure if they're being Release'd properly in the _Copy policy classes. . .

Tony


Quote:
> //////////////////////////////////
> // DEDUG ROUTINES

>  int  tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
>  // Turn on leak-checking
>   tmpFlag |=  _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF ;
>   // Set flag to the new value
>   _CrtSetDbgFlag( tmpFlag );

> //END DEBUG ROUTINES
> //////////////////////////////////

> Use this code in your starting point (main .cpp, _tWinMain or DllMain).
> when you end your program you will see memory leak report if there are
some
> leaks.
> --
> Michail
> MCP,MCSD


> > Hi everyone,

> > I've started to write an ICollectionOnSTL-based class for a thumbnail
> > control that will be scripted against in Internet Explorer and I'm
hoping
> > that someone can check my use of CAdapt< CComPtr< > > in the
> > ICollectionOnSTLImpl template and _Copy classes with special regards for
> the
> > reference counting of the contained CComPtr elements--The collection
seems
> > to work fine so far, but I'd like to make sure there are no memory leaks
> > before going much further.. Thanks!

> > Anthony Davis



Mon, 17 May 2004 00:16:21 GMT  
 ICollectionOnSTL / CComEnumOnSTL
Debug your dll with VC++ IDE.You can chose executable which will use your
dll (ActiveX cont. in your situation)

#define _ATL_DEBUG_INTERFACES
 enables reference-count debugging



Quote:
> Thanks, but how do I see the debug output from my DLL (I'm testing the
> control in Internet Explorer/ActiveX Control Test Container)?  Also, isn't
> it possible that COM memory leaks (from AddRef()s w/o matching Release()s)
> will still not be detected this way?  Specifically, my collection class is
> designed to hold smart pointers to externally created (in script) IThumb
> objects which are AddRef'd when the collection is enumerated and I'm not
> sure if they're being Release'd properly in the _Copy policy classes. . .

> Tony



> > //////////////////////////////////
> > // DEDUG ROUTINES

> >  int  tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
> >  // Turn on leak-checking
> >   tmpFlag |=  _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF ;
> >   // Set flag to the new value
> >   _CrtSetDbgFlag( tmpFlag );

> > //END DEBUG ROUTINES
> > //////////////////////////////////

> > Use this code in your starting point (main .cpp, _tWinMain or DllMain).
> > when you end your program you will see memory leak report if there are
> some
> > leaks.
> > --
> > Michail
> > MCP,MCSD


> > > Hi everyone,

> > > I've started to write an ICollectionOnSTL-based class for a thumbnail
> > > control that will be scripted against in Internet Explorer and I'm
> hoping
> > > that someone can check my use of CAdapt< CComPtr< > > in the
> > > ICollectionOnSTLImpl template and _Copy classes with special regards
for
> > the
> > > reference counting of the contained CComPtr elements--The collection
> seems
> > > to work fine so far, but I'd like to make sure there are no memory
leaks
> > > before going much further.. Thanks!

> > > Anthony Davis



Mon, 17 May 2004 01:04:58 GMT  
 ICollectionOnSTL / CComEnumOnSTL
Here are the way how you can set up your dll for debug:
Project, Settings, Debug tab, Executable for debug session.


Quote:
> Thanks, but how do I see the debug output from my DLL (I'm testing the
> control in Internet Explorer/ActiveX Control Test Container)?  Also, isn't
> it possible that COM memory leaks (from AddRef()s w/o matching Release()s)
> will still not be detected this way?  Specifically, my collection class is
> designed to hold smart pointers to externally created (in script) IThumb
> objects which are AddRef'd when the collection is enumerated and I'm not
> sure if they're being Release'd properly in the _Copy policy classes. . .

> Tony



> > //////////////////////////////////
> > // DEDUG ROUTINES

> >  int  tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
> >  // Turn on leak-checking
> >   tmpFlag |=  _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF ;
> >   // Set flag to the new value
> >   _CrtSetDbgFlag( tmpFlag );

> > //END DEBUG ROUTINES
> > //////////////////////////////////

> > Use this code in your starting point (main .cpp, _tWinMain or DllMain).
> > when you end your program you will see memory leak report if there are
> some
> > leaks.
> > --
> > Michail
> > MCP,MCSD


> > > Hi everyone,

> > > I've started to write an ICollectionOnSTL-based class for a thumbnail
> > > control that will be scripted against in Internet Explorer and I'm
> hoping
> > > that someone can check my use of CAdapt< CComPtr< > > in the
> > > ICollectionOnSTLImpl template and _Copy classes with special regards
for
> > the
> > > reference counting of the contained CComPtr elements--The collection
> seems
> > > to work fine so far, but I'd like to make sure there are no memory
leaks
> > > before going much further.. Thanks!

> > > Anthony Davis



Mon, 17 May 2004 01:07:27 GMT  
 ICollectionOnSTL / CComEnumOnSTL
Thanks Michail,

I actually found that destroy() in both of my custom copy classes is never
called... Does anyone know why this is? My copy classes look like this:

typedef CComQIPtr<IThumb>      SPThumb;

class _CopyIThumbFromIThumbAdapter
{
public:
    static HRESULT copy(IThumb** p1, CAdapt<SPThumb>* p2)
 {
  *p1 = reinterpret_cast<IThumb*>(p2); // Q: Is this safe?
  if (*p1)
   (*p1)->AddRef();

  return (p1 ? S_OK : E_NOINTERFACE);
    }

    static void init(SPThumb *p) {;}
    static void destroy(SPThumb *p) { if (*p) p->Release(); }

Quote:
};

class _CopyVariantFromIThumbAdapter
{
public:
    static HRESULT copy(VARIANT* p1, CAdapt<SPThumb>* p2)
 {
  p2->m_T.p->AddRef();

  CComVariant v(p2->m_T);
  v.Detach(p1);

  return (p1 ? S_OK : E_NOINTERFACE);
    }

    static void init(VARIANT *p) {;}
    static void destroy(VARIANT *p) { if (p) p->pdispVal->Release(); }

Quote:
};



Mon, 17 May 2004 05:01:56 GMT  
 ICollectionOnSTL / CComEnumOnSTL
If your destructor is never call, it means that you have problem with
AddRef/Release calls.
Use flag for interfase ref. debug.

--
Michail
MCP,MCSD


Quote:
> Thanks Michail,

> I actually found that destroy() in both of my custom copy classes is never
> called... Does anyone know why this is? My copy classes look like this:

> typedef CComQIPtr<IThumb>      SPThumb;

> class _CopyIThumbFromIThumbAdapter
> {
> public:
>     static HRESULT copy(IThumb** p1, CAdapt<SPThumb>* p2)
>  {
>   *p1 = reinterpret_cast<IThumb*>(p2); // Q: Is this safe?
>   if (*p1)
>    (*p1)->AddRef();

>   return (p1 ? S_OK : E_NOINTERFACE);
>     }

>     static void init(SPThumb *p) {;}
>     static void destroy(SPThumb *p) { if (*p) p->Release(); }
> };

> class _CopyVariantFromIThumbAdapter
> {
> public:
>     static HRESULT copy(VARIANT* p1, CAdapt<SPThumb>* p2)
>  {
>   p2->m_T.p->AddRef();

>   CComVariant v(p2->m_T);
>   v.Detach(p1);

>   return (p1 ? S_OK : E_NOINTERFACE);
>     }

>     static void init(VARIANT *p) {;}
>     static void destroy(VARIANT *p) { if (p) p->pdispVal->Release(); }
> };



Mon, 17 May 2004 18:19:42 GMT  
 ICollectionOnSTL / CComEnumOnSTL
Some of the CComVariant constructors/code (as well some Variantxxx APIs)
will do AddRefs if the type looks like an interface pointer. I wonder if
that's what you're seeing here.



Quote:
> Thanks Michail,

> I actually found that destroy() in both of my custom copy classes is never
> called... Does anyone know why this is? My copy classes look like this:

> typedef CComQIPtr<IThumb>      SPThumb;

> class _CopyIThumbFromIThumbAdapter
> {
> public:
>     static HRESULT copy(IThumb** p1, CAdapt<SPThumb>* p2)
>  {
>   *p1 = reinterpret_cast<IThumb*>(p2); // Q: Is this safe?
>   if (*p1)
>    (*p1)->AddRef();

>   return (p1 ? S_OK : E_NOINTERFACE);
>     }

>     static void init(SPThumb *p) {;}
>     static void destroy(SPThumb *p) { if (*p) p->Release(); }
> };

> class _CopyVariantFromIThumbAdapter
> {
> public:
>     static HRESULT copy(VARIANT* p1, CAdapt<SPThumb>* p2)
>  {
>   p2->m_T.p->AddRef();

>   CComVariant v(p2->m_T);
>   v.Detach(p1);

>   return (p1 ? S_OK : E_NOINTERFACE);
>     }

>     static void init(VARIANT *p) {;}
>     static void destroy(VARIANT *p) { if (p) p->pdispVal->Release(); }
> };



Tue, 25 May 2004 06:08:30 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. ICollectionOnSTL / CComEnumOnSTL

2. ICollectionOnSTL in VC7

3. New Undocumented ATL Interface: ICollectionOnSTL

4. CComEnumOnSTL / ICollectionOnSTLImpl & Copy Policies

5. Fw: CComEnumOnSTL Thread Safety

6. CComEnumOnSTL

7. CComEnumOnSTL Thread Safety

8. CComEnumOnSTL

9. _com_error and CComEnumOnSTL support

 

 
Powered by phpBB® Forum Software