AActor::CanBeInCluster
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtualoverride
Description
Returns whether this actor is eligible to be grouped into a GC cluster, which improves Garbage Collection performance by treating a set of objects as a single unit. Controlled by the `bCanBeInCluster` property.
Caveats & Gotchas
- • The base AActor implementation returns the value of the `bCanBeInCluster` UPROPERTY — actors with mutable state that references objects outside the cluster can cause GC correctness issues if clustering is enabled.
- • Clustering is an optimization; if an actor holds references to dynamically loaded assets or other actors that may be separately collected, override this to return false to avoid stale-reference bugs.
Signature
ENGINE_API virtual bool CanBeInCluster() const override; Return Type
bool Example
Prevent a specific actor type from clustering C++
bool AMyDynamicActor::CanBeInCluster() const
{
// This actor holds external references that can change at runtime,
// so it must not participate in GC clusters.
return false;
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?