# Where is ActorComponent's GC Reference managed?

**URL:** <https://forums.unrealengine.com/t/where-is-actorcomponents-gc-reference-managed/2278162>\
**Category:** Programming & Scripting\
**Tags:** garbage-collection, unreal-engine, CPP, question\
**Created:** [January 15, 2025, 11:22am UTC](https://forums.unrealengine.com/t/where-is-actorcomponents-gc-reference-managed/2278162 "2025-01-15T11:22:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chul2ya](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@chul2ya](https://forums.unrealengine.com/u/chul2ya)\
**Post date:** [January 15, 2025, 11:22am UTC](https://forums.unrealengine.com/t/where-is-actorcomponents-gc-reference-managed/2278162/1 "2025-01-15T11:22:38Z")

</div>

Hello.

First of all, I ask for your understanding of using a translator due to my lack of English skills.

We thought that the GC Reference of the ActorComponent was managed by the Actor who owns the ActorComponent.

[https://dev.epicgames.com/community/learning/knowledge-base/ePKR/unreal-engine-garbage-collector-internals](https://dev.epicgames.com/community/learning/knowledge-base/ePKR/unreal-engine-garbage-collector-internals)

When I read the document, Outer is not related to GC and it seems important whether UPROPERTY marking or not.

In other words, the actor must have the actor components as UPROPERTY in order to manage the actor component’s GC Reference.

(Unless it is managed by the FReferenceCollector)

When you look at the Actor.h file, there are the following member variables.

UPROPERTY(Instanced)  
TArray\<TObjectPtr\> InstanceComponents;  
UPROPERTY(TextExportTransient, NonTransactional)  
TArray\<TObjectPtr\> BlueprintCreatedComponents;  
TSet\<TObjectPtr\> OwnedComponents;

Okay, I think it will probably be registered with BlueprintCreatedComponents or InstanceComponents. There are many ways to create an ActorComponent, but I wrote the test code for calling NewObject → RegisterComponents.

I created an ATestActor class that can be placed at the level and overridden the BeginPlay function as follows.

```auto
void ATestActor::BeginPlay()
{
	Super::BeginPlay();

	USceneComponent* SceneComponent = NewObject<USceneComponent>(this, USceneComponent::StaticClass());
	SceneComponent->RegisterComponent();
	
	TArray<UObject*> Referencees { SceneComponent };
	TArray<UObject*> Objects = FReferencerFinder::GetAllReferencers(Referencees, nullptr);
	for (UObject* Object : Objects)
	{
		UE_LOG(LogTemp, Log, TEXT("%s"), *Object->GetName());
		
		AActor* Actor = Cast<AActor>(Object);
		if (IsValid(Actor))
		{
			for (UActorComponent* Component : Actor->BlueprintCreatedComponents)
			{
				UE_LOG(LogTemp, Log, TEXT("Blueprint Created Components : %s"), *Component->GetName());
			}
			for (UActorComponent* Component : Actor->GetInstanceComponents())
			{
				UE_LOG(LogTemp, Log, TEXT("Instance Components : %s"), *Component->GetName());
			}
			for (UActorComponent* Component : Actor->GetComponents())
			{
				UE_LOG(LogTemp, Log, TEXT("Owned Component : %s"), *Component->GetName());
			}
		}
	}
}

```

When you placed ATestActor at the level and pressed Run, the results are as follows.

LogTemp: TestActor\_UAID\_107C61B31D5EE84202\_1576081023  
LogTemp: Owned Component : SceneComponent\_0

SceneComponent is not part of the InstanceComponents, BlueprintCreatedComponents.  
Where do you manage GC Reference?

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [January 15, 2025, 1:38pm UTC](https://forums.unrealengine.com/t/where-is-actorcomponents-gc-reference-managed/2278162/2 "2025-01-15T13:38:50Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/2/0520f3c9e83d0672bfd6ea86574d38631bfde309.png)

---

<div class="post-metadata">

**Author:** ![chul2ya](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@chul2ya](https://forums.unrealengine.com/u/chul2ya)\
**Post date:** [January 16, 2025, 5:04am UTC](https://forums.unrealengine.com/t/where-is-actorcomponents-gc-reference-managed/2278162/3 "2025-01-16T05:04:25Z")

</div>

Thank you. I should have looked at the documents more carefully, i’m sorry.

I didn’t think it was going to go from there because there was no place to call that function. I thought it was simply a feature close to a helper.

The AddReferencedObjects function is registered in the UOBJECT\_CPPCLASS\_STATICFUNCTIONS\_ALLCONFIGS macro.

This macro belongs to IMPLEMENT\_CLASS and is used in the .gen.cpp file generated by UHT.

And that function is called in the GC process.

Thanks once again.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 15, 2025, 5:05am UTC](https://forums.unrealengine.com/t/where-is-actorcomponents-gc-reference-managed/2278162/4 "2025-02-15T05:05:14Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
