# UE4 Delegate, Suddenly unbounded in runtime

**URL:** <https://forums.unrealengine.com/t/ue4-delegate-suddenly-unbounded-in-runtime/269887>\
**Category:** C++\
**Tags:** UE4-22, unreal-engine, question, UE4-27\
**Created:** [January 3, 2022, 4:13pm UTC](https://forums.unrealengine.com/t/ue4-delegate-suddenly-unbounded-in-runtime/269887 "2022-01-03T16:13:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![public\_float\_hp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@public\_float\_hp](https://forums.unrealengine.com/u/public_float_hp)\
**Post date:** [January 3, 2022, 4:13pm UTC](https://forums.unrealengine.com/t/ue4-delegate-suddenly-unbounded-in-runtime/269887/1 "2022-01-03T16:13:46Z")

</div>

Hello, In my project, there is a class which has a delegate as a member variable.  
My CharacterClass has that class and some function would be bound with the delegate in the class.

Q. Suddenly, the binding is unbound. What happened to this? It seems that GC activated but I don’t understand clearly.

Here is my ClassA.h

```auto
UCLASS()
class SECONDARYPRACTICE2_API UClassA : public UObject
{
	GENERATED_BODY()
public:
	FVoidNotier Notier; //FVoidNotier is a delegate created by DECLARE_DELEGATE
};

```

Here are my CharacterClass’s BeginPlay( ) and Tick( )

```auto
void ASecondaryPractice2Character::BeginPlay()
{
	Super::BeginPlay();
	ClassA = NewObject<UClassA>();
	ClassA->Notier.BindLambda([=]() {UE_LOG(LogTemp, Warning, TEXT("Calling from ClassA")); });
}

void ASecondaryPractice2Character::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (ClassA == nullptr)
	{
		UE_LOG(LogTemp, Warning, TEXT("ClassA is Null"));
	}
	else
	{
		if (ClassA->Notier.IsBound() == false)
		{
			UE_LOG(LogTemp, Warning, TEXT("ClassA's Delegate is not bound@@@@"));
		}
		else
		{
			ClassA->Notier.ExecuteIfBound();
		}
	}
}

```

As long as ClassA is not null and ClassA’s Delegate is bound, “Calling from ClassA” would be printed. But suddenly, “ClassA’s Delegate is not bound@@@@” is being printed…  
 ![UnboundSample](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/0/606b7acd84d086449be14fdbdcbdb6f8f80287d1.gif)

What happened to this?

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [January 4, 2022, 12:51am UTC](https://forums.unrealengine.com/t/ue4-delegate-suddenly-unbounded-in-runtime/269887/2 "2022-01-04T00:51:00Z")

</div>

Is the ClassA property declared UPROPERTY() ?

---

<div class="post-metadata">

**Author:** ![public\_float\_hp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@public\_float\_hp](https://forums.unrealengine.com/u/public_float_hp)\
**Post date:** [January 4, 2022, 1:11am UTC](https://forums.unrealengine.com/t/ue4-delegate-suddenly-unbounded-in-runtime/269887/3 "2022-01-04T01:11:24Z")

</div>

No It is not. However, because ClassA is still not nullptr, I thought ClassA wasn’t collected by GC so ClassA’s delegate’s binding was still safe. And I am going to store those kinds of ClassA in TMap.  
Anyway, I will try put UPROPERTY on the ClassA.  
Thank you.

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [January 4, 2022, 1:42am UTC](https://forums.unrealengine.com/t/ue4-delegate-suddenly-unbounded-in-runtime/269887/4 "2022-01-04T01:42:41Z")

</div>

If your pointer isn’t UPROPERTY than GC doesn’t know your pointer exists, so if there’s no UPROPERTY pointers holding a reference to it, it will garbage collect.

---

<div class="post-metadata">

**Author:** ![public\_float\_hp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@public\_float\_hp](https://forums.unrealengine.com/u/public_float_hp)\
**Post date:** [January 4, 2022, 12:54pm UTC](https://forums.unrealengine.com/t/ue4-delegate-suddenly-unbounded-in-runtime/269887/5 "2022-01-04T12:54:21Z")

</div>

Thank you. You are right.  
With UPROPERTY, Even though I called GC manually It wasn’t collected.  
One thing that I wonder is that if the delegate’s binding is a target of GC.  
Anyway thank you again!
