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
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