I recently studied.
That UPROPERTY variables use strong references.
So I have a question.
We know that complex strong reference relationships make GC difficult.
Does the act of setting the value to null when the object is destroyed help with GC performance?
Here’s my simple example.
header
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TestActor.generated.h"
UCLASS()
class ATestActor : public AActor
{
GENERATED_BODY()
public:
ATestActor();
protected:
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayResult) override;
public:
UPROPERTY()
class ABaseCharacter* Character;
};
source
#include "TestActor.h"
//..
void ATestActor::EndPlay(const EEndPlayReason::Type EndPlayResult)
{
// do we need to do this?
Character = nullptr;
Super::EndPlay(EndPlayResult);
}
Is it recommended?
Or is the engine already doing it?