Managed memory – smart pointers (TSharedPtr, TWeakPtr, TAutoPtr) to track an object

When people are afraid that they'll forget the delete call for standard C++ objects they create, they often use smart pointers to prevent memory leaks. TSharedPtr is a very useful C++ class that will make any custom C++ object reference-counted—with the exception of UObject derivatives, which are already reference-counted. An alternate class TWeakPtr is also provided for pointing to a reference-counted object with the strange property of being unable to prevent deletion (hence, "weak").

Managed memory – smart pointers (TSharedPtr, TWeakPtr, TAutoPtr) to track an object

Tip

UObject and it's derivative classes (anything created with NewObject or ...

Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.