The code below demonstrates how having a const function variable a strong referenced singleton is wrongfully deleted
class InfiniteRefContainer { static const ref InfiniteRefContainer s_Singleton = new InfiniteRefContainer(); void InfiniteRefContainer() { PrintFormat(ToString() + "::ctor()"); } void ~InfiniteRefContainer() { PrintFormat(ToString() + "::dtor()"); } static InfiniteRefContainer GetContainer() { return s_Singleton; } } ... void TestRef() { const InfiniteRefContainer infiniteContainer = InfiniteRefContainer.GetContainer(); Print(infiniteContainer); }
SCRIPT : InfiniteRefContainer<0x000002BB76842CE0>::ctor()
SCRIPT : InfiniteRefContainer infiniteContainer = InfiniteRefContainer<0x000002BB76842CE0>
SCRIPT : InfiniteRefContainer<0x000002BB76842CE0>::dtor()