AActor::MarkComponentsAsGarbage
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Marks all components as garbage so the GC can collect them when the actor is destroyed. This is the UE5.3+ replacement for the deprecated MarkComponentsAsPendingKill.
Caveats & Gotchas
- • MarkComponentsAsPendingKill was deprecated in UE 5.3 and now simply calls this function — update any engine-version-conditional code accordingly.
- • Passing bModify=false skips the transaction record, which means the destruction will not appear in the undo history; only do this when undo support is not needed (e.g. during level teardown).
Signature
ENGINE_API virtual void MarkComponentsAsGarbage(bool bModify = true); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bModify | bool | If true, Modify() is called on the actor before marking components, dirtying the transaction buffer for undo support. | true |
Return Type
void Example
Called automatically during actor destruction C++
// You almost never call this directly.
// The engine calls it from UWorld::DestroyActor.
// If subclassing, you can override to also mark custom resources:
void AMyActor::MarkComponentsAsGarbage(bool bModify)
{
Super::MarkComponentsAsGarbage(bModify);
// Mark any additional owned UObjects here
} See Also
Tags
Version History
Introduced in: 5.3
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.3 | stable | Introduced as replacement for the deprecated MarkComponentsAsPendingKill. |
Feedback
Was this helpful?