mtlpp
mtlpp copied to clipboard
There are several fatal memory leaks in the wrapper code.
Please see https://github.com/naleksiev/mtlpp/pull/6 for more details. Looking forward to your thoughts on this subject. Thank you.
I've been using ObjC mainly with ARC and I'm still trying to figure out for myself the problem. I saw some changes to mtlpp made by Epic engineers to fix the over retaining of objects. Seems like when I'm default constructing object I'm adding extra retain. The solution they have implemented is to have optional retain parameter for the Object constructor:
Object(const Handle& handle, bool retain = true);
And then retain is set to false everywhere [[... alloc] init] is used:
TextureDescriptor::TextureDescriptor() :
ns::Object(ns::Handle{ (__bridge void*)[[MTLTextureDescriptor alloc] init] }, false)
{
}
Hi,
Your comment
ObjC mainly with ARC
is the key to the issue here. The Epic's fix only makes sense when ARC is turned off. Otherwise the code is okay and not leaking.