Knowledge Base: How to register disregard for GC objects

Introduction
Following the UE4 object lifecycle, we create objects as needed and destroy them when no longer needed. Destroyed objects are eventually deleted from memory by the garbage collection system (GC). It is usefu…

https://dev.epicgames.com/community/learning/knowledge-base/dPae/unreal-engine-how-to-register-disregard-for-gc-objects

2 Likes

Just in case someone else runs into this:
It needn’t be the GameInstance, by the way. It can be any native class.

The engine creates the ClassDefaultObject for all native classes before closing the DisregardForGC pool. One can just make a new small class that only overrides PostInitProperties() and does the loading.