memory leak when use _com_ptr_t

  • Thread starter Life as I know it
  • Start date
L

Life as I know it

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
 
R

red floyd

Life said:
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.html#faq-5.9
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

operator= could not be generated 6
Memory Leak 5
Help with policy based design 3
Memory Leak Detection 11
memory leak 3
Memory Leak 16
Memory Leak detection 1
Does this function leak memory? 2

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top