Deleting a USaveGame Pointer causes a hard crash

Hey Team,

When I attempt to delete a pointer to a Save Game in my classes deconstructor it causes a hard-crash. I am using a custom USaveGame pointer and am creating it through the same function calls as in the SaveGame tutorial.

SaveGame = Cast<UMySaveGame>(UGameplayStatics::CreateSaveGameObject(UMySaveGame::StaticClass()));

and in the deconstructor

delete(SaveGame);

In the example code there is no deletion of the pointer but also no mention that it doesn’t need to be deleted.

How should I deal with the deconstruction of the class with ownership of this save game pointer? Can we get this added to the documentation or within the SaveGame.h’s comments?

Cheers,
Mugen

Why are you trying to delete a UObject? Its reference counted.

UObjects are garbage collected and shouldn’t be explicitly deleted, see Unreal Object Handling | Unreal Engine Documentation

Righto, cheers Enlight.