I load a dll which writen in c++, in this dll ,C++ manages memory requests and releases, for example, the function: Init( ref IntPtr connectHandle) to request, Close(IntPtr connectHandle) to release; In my code:
class Test
{
public IntPtr _connectHandle;
public Init()
{
cPlusPlus(ref connectHandle);
}
public Close()
{
cPlusPlus(_connectHandle);
}
~Test()
{
Close();
}
}
There are two object Test a and Test b, b = a.Clone()--There Clone() is deep copy. And two question worry to me.
- When I don't use b, Is set b = null, but b had IntPtr Type, it can be released by GC?
- If can, GC will release the memory which requsted by c++;