- Unreal Engine 4.x Scripting with C++ Cookbook
- John P. Doran William Sherif Stephen Whittle
- 203字
- 2025-02-28 12:28:30
How it works...
The ConditionalBeginDestroy() function begins the destruction process by removing all internal engine linkages to it. This marks the object for destruction as far as the engine is concerned. The object is then destroyed some time later by destroying its internal properties, followed by actual destruction of the object.
After ConditionalBeginDestroy() has been called on an object, your (client) code must consider the object to be destroyed, and must no longer use it.
Actual memory recovery happens some time later than when ConditionalBeginDestroy() has been called on an object. There is a garbage collection routine that finishes clearing the memory of objects that are no longer referenced by the game program at fixed time intervals. The time interval between garbage collector calls is listed in C:\Program Files (x86)\Epic Games\Launcher\Engine\Config\BaseEngine.ini, and defaults to one collection every 61.1 seconds:
gc.TimeBetweenPurgingPendingKillObjects=61.1
Usually, you do not need to worry about garbage collection or the interval unless you urgently need memory cleared. Do not call garbage collection routines too often, as this may cause unnecessary lag in the game.