Exploring core mechanics
In this section, we will delve into more sophisticated features, such as memory management and reflection, and explain how Unreal Engine copes with them.
Garbage collection
As you may already know, garbage collection (GC) is a way to automatically manage memory. In a GC-managed system, once an object is no longer used, it will be automatically removed from memory to free space. This allows you to create a new object and use it, and when you’re finished using it, you will simply be good to go. This system is managed by the garbage collector, which constantly monitors which objects are still in use. When an object is no longer needed, the garbage collector automatically frees up the associated memory.
While GC is used by many modern programming languages – such as C# and Python – lower-level languages such as C and C++ do not include a garbage collector by default. As a result, programmers must manually track memory usage and free...