FGCArrayPool& ArrayPool = FGCArrayPool::Get(); TArray<FGCArrayStruct*> AllArrays; ArrayPool.GetAllArrayStructsFromPool(AllArrays); // This needs to happen before clusters get dissolved otherwisise cluster information will be missing from history ArrayPool.UpdateGCHistory(AllArrays);
// Reconstruct clusters if needed if (GUObjectClusters.ClustersNeedDissolving()) { constdouble StartTime = FPlatformTime::Seconds(); GUObjectClusters.DissolveClusters(); UE_LOG(LogGarbage, Log, TEXT("%f ms for dissolving GC clusters"), (FPlatformTime::Seconds() - StartTime) * 1000); }
// Fire post-reachability analysis hooks { TRACE_CPUPROFILER_EVENT_SCOPE(BroadcastPostReachabilityAnalysis); FCoreUObjectDelegates::PostReachabilityAnalysis.Broadcast(); }
// This needs to happen after NotifyGarbageReferencers and GatherUnreachableObjects since both can mark more objects as unreachable ArrayPool.ClearWeakReferences(AllArrays);
// Now return arrays back to the pool and free some memory if requested for (int32 Index = 0; Index < AllArrays.Num(); ++Index) { FGCArrayStruct* ArrayStruct = AllArrays[Index]; if (bPerformFullPurge || Index % 7 == 3) // delete 1/7th of them just to keep things from growing too much between full purges { ArrayPool.FreeArrayStruct(ArrayStruct); } else { ArrayPool.ReturnToPool(ArrayStruct); } }
// Make sure nothing will be using potentially freed arrays AllArrays.Empty();