Search code examples
c++unreal-engine4

Is Unreal Engine 4 C++ managed or unmanaged?


Unreal Engine 4 controls some runtime aspects of the application, such as having its own Garbage Collector and a unique metadata ("reflection") system.

The question is: is it correct to say UE4 makes the C++ code "managed" in the context of "managed" and "unmanaged" languages (as in C# is a managed language and C++ is an unmanaged language)?


Solution

  • If by "managed" you mean "managed memory" meaning "garbage collected" then C++ allows you to opt-in to that if you so wish, but by default it does not offer such a thing.

    C#, like Java and many others, forces garbage collection on you, there is no way around it.

    In C++ you can use things like std::shared_ptr to wrap around any objects you want to be garbage collected.

    Remember that in C++ there's many ways to allocate and initialize. In situations where performance must be optimized at the expense of complexity it's not uncommon to write a custom allocator that can cut a lot of corners so long as it's used a very specific way.

    So in other words C++ is "managed" if you want and how you want it to be managed. Management in C++ is a process you're an active participant in.