I followed this tutorial: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums to create a static library.
It is a great tutorial. However I noticed when implementing a UFunction, they create a c++ object using the new keyword, allocating memory, than return from the function without deleting the memory.
so my question is, since this is happening inside of a UFunction, is the memory managed? Or is this a memory leak?
.h
UCLASS()
class UE4MAGIC_API UYJLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Adds floats", Keywords = "Float Add"), Category = YJLibrary)
static float AddFloats(float A, float B);
};
.cpp
#include "YJLibrary.h"
#include "YJMagic.h"
float UYJLibrary::AddFloats(float A, float B)
{
YJMagic::YJMagic *PointerToYJMagic;
PointerToYJMagic = new YJMagic::YJMagic();
return PointerToYJMagic->Add(A, B);
}