Using Blueprint inherits a custom C++ GameInstance will not cleanup its UPROPERTY variables

Using Blueprint inherits a custom C++ GameInstance will not cleanup its UPROPERTY variables

When Play in Editor(Does not close the Editor).
The UPROPERTY variables in C++ GameInstance class won’t cleanup. The UPROPERTY variables always point to the same memory addresses. The contents of the variables are always the same of last PIE sessoin.

But using the custom C++ GameInstance class directly won’t reproduce the same issue.
It works fine. The UPROPERTY variables seem initialize correctly when launch a new PIE.

Hey -

Could you elaborate on what your issue is? How are you setting up your game instance? What UPROPERTY variables are you setting up in your GameInstance class? Could you post the code for your class as well as explain how you’re setting it in the editor and how you’re checking the value of your game instance variables during PIE?

Cheers

Sorry. It’s our fault.
We create UPROPERTY variables at Gameinstance’s constructor and called AddToRoot of these variables.

It causes the GameInstance not correctly destroyed.

I’m glad to hear that you were able to discover the cause to the issue you were having and were able to solve it. I will mark this post as resolved since yo u were able to fix the problem, however it would also be helpful if you could explain how you fixed the issue in case the same thing occurs for someone else.

We create these UObjects in GameInstance’s Init Method.

void UMyGameInstance::Init()
{
    Super::Init();
........................................
    MyObject = NewObject<UMyObject>(this);
........................................
}

class UMyGameInstance : public UGameInstance
{
........................................
    UPROPERTY()
    UMyObject* MyObject;
........................................

};