How to delete (free) a variable which is created from NewObject function?

Hello everyone,

I have an actor which creates a dynamic object inside of its BeginPlay function. I want to delete (free) this variable inside of EndPlay function. How can I free that memory?

Example code:

void AWeapon::BeginPlay()
    // Create a new object
	Curve = NewObject<UCurveVector>(this);

void AWeapon::EndPlay(const EEndPlayReason::Type EndPlayReason)

	// How to free the variable 'Curve' in here?

If you’re alright to rely on the UE4 Garbage Collector (which is really the intended way to use UE4) then you can just set the variable to NULL and let the Garbage Collector do it’s thing. Remember to mark your Curve variable as UPROPERTY(Transient) or similar though.