中EN

Incremental Garbage Collection

  • Experimental. UE uses mark-and-sweep; reachability analysis must complete in a single frame, stopping UObject processing → hitches proportional to object count. Workarounds: tight UObject budgets, pools, disabling GC during gameplay.
  • Incremental reachability analysis splits it across frames with per-frame soft time limit; references tracked via TObjectPtr properties — assignment to a TObjectPtr UPROPERTY marks object reachable during GC ("garbage collector write barrier"). Must convert all UPROPERTY raw pointers to TObjectPtr or objects may be reclaimed too early.
  • Enable: gc.AllowIncrementalReachability=1, gc.AllowIncrementalGather=1, gc.IncrementalReachabilityTimeLimit=0.002.
  • Debug cvars: gc.DelayReachabilityIteration, gc.VerifyNoUnreachableObjects, gc.ContinuousIncrementalGC.
  • Known limitation: not fully thread safe; objects manipulated on worker threads may not be marked reachable → premature GC. Recommend single-threaded builds only (e.g. dedicated servers).

引用这一章的笔记

输入关键词开始搜索

滚轮或双指缩放 · 拖动平移 · 双击放大 / 还原