我正在开发一个统一的ios插件。将iOS上的id<MTLTexture>
发送到IntPtr
统一发送。
IOS:
typedef struct
{
void* texPtr;
}Ios_Struct;
id<MTLTexture> mtlTex; // produced otherwhere, ARC
void foo_caller()
{
ios_struct toBeSent;
toBeSent.texPtr = (__bridge_retained void*)mtlTex;
// call the callback that registered from Unity
unityCallBack(toBeSent);
// should I DO a release operation on the [toBeSent.texPtr]?
// (__bridge_transfer id<MTLTexture>)toBeSent.texPtr;
}
团结:
public struct Unity_Struct;
{
public IntPtr texPtr;
}
public delegate void Internal_Callback(Unity_Struct data);
// the callback that to be registered into IOS
[MonoPInvokeCallback(typeof(Internal_Callback))]
private static void toBeCalled(Unity_Struct sentData)
{
IntPtr texPtr = sentData.texPtr;
// to use the texPtr
}
我想知道从id<MTLTexture>
到void*
到intPtr
是否存在内存泄漏。
如果有,通过以下步骤释放toBeSent.texPtr
是否正确:
// should I DO a release operation on the [toBeSent.texPtr]?
(__bridge_transfer id<MTLTexture>)toBeSent.texPtr;