[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

memory leak when use _com_ptr_t

Life as I know it

12/8/2008 3:37:00 PM

I wrote a class to use C# com in C++ project, but everytime i new A()
and delete A; it will cause memory leak the memeory increase but no
return.
i have debuged into the _com_ptr_t::release function when i call
delete A but from the memory check tool the memory doesn't returned.


#import ".....\bridge.tlb"
class A
{
A();
~A();
Func1();
m_Ptr;
}
A()
{
m_Ptr = NULL;
Bridge::_ObjPtr obj(__uuidof(Bridge::Obj));
m_Ptr = (void *) obj.Detach();
}
~A()
{
Bridge::_ObjPtr obj;
obj.Attach((Bridge::_ObjPtr *)m_Ptr );
}
Func1()
{
Bridge::_ObjPtr obj;
obj.Attach((Bridge::_ObjPtr *)m_Ptr );
...
obj.function();//do someing with the obj
...
obj.Detach();
}

Is anybody have any ideas? what's wrong with me code?
Thanks in advance
2 Answers

red floyd

12/8/2008 3:48:00 PM

0

Life as I know it wrote:
> I wrote a class to use C# com in C++ project, but everytime i new A()
> and delete A; it will cause memory leak the memeory increase but no
> return.
> i have debuged into the _com_ptr_t::release function when i call
> delete A but from the memory check tool the memory doesn't returned.
>

This is off topic. COM, C# and the Windows and .NET APIs are off topic.

Please try again by asking in a newsgroup with "Microsoft" or "Windows"
in its name. See FAQ 5.9 for a list of sugggested newsgroups.

http://www.parashift.com/c++-faq-lite/how-to-post.ht...

Life as I know it

12/8/2008 4:18:00 PM

0

On Dec 8, 11:48 pm, red floyd <no.spam.h...@example.com> wrote:
> Life as I know it wrote:
>
> > I wrote a class to use C# com in C++ project, but everytime i new A()
> > and delete A; it will cause memory leak the memeory increase but no
> > return.
> > i have debuged into the _com_ptr_t::release function when i call
> > delete A but from the memory check tool the memory doesn't returned.
>
> This is off topic.  COM, C# and the Windows and .NET APIs are off topic.
>
> Please try again by asking in a newsgroup with "Microsoft" or "Windows"
> in its name.   See FAQ 5.9 for a list of sugggested newsgroups.
>
> http://www.parashift.com/c++-faq-lite/how-to-post.ht...

Thank you i've got the wrong place