I have a C++ class not extending anything, it acts as a wrapper around a library, for use in Unreal Engine 4.
Initially I had the UTexture defined like this:
private:
UTexture2D *Texture;
However, after creating the texture using CreateTransient
, I noticed it got destroyed after 50-60 seconds. ■■■■… the garbage collector is at it.
I ended up fixing this by making it a UProperty, and after initializing the texture, calling AddToRoot.
But I was wondering, is this the only way? How come my initial way doesn’t count as “keeping a reference” even though the wrapper never “dies”?