mtlpp icon indicating copy to clipboard operation
mtlpp copied to clipboard

There are several fatal memory leaks in the wrapper code.

Open narendraumate opened this issue 6 years ago • 2 comments

Please see https://github.com/naleksiev/mtlpp/pull/6 for more details. Looking forward to your thoughts on this subject. Thank you.

narendraumate avatar Aug 26 '17 09:08 narendraumate

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)
    {
    }

naleksiev avatar Sep 14 '17 05:09 naleksiev

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.

BartSiwek avatar Oct 31 '17 18:10 BartSiwek