UUserWidget pointer is filled with garbage value on runtime, c++

I created UUserWidget and stored it’s pointer into TMap. I didn’t use AddtoViewport right after the pointer is created at first because I want to use AddtoViewport when I want on runtime. However, the pointer is filled with garbage value when I access it to use AddtoViewport(). Do I have to use AddtoViewport() right after creating UUserWidget?
Is there any solution about this situation?
Thanks.

   <.h>
    TMap<eWIDGET, UUserWidget*> WidgetMap;
    
    <.cpp>
void AFP_PlayerController::BeginPlay()
{
    FName Path = TEXT("WidgetBlueprint'/Game/WidgetBP/FP_StatusWidget_BP.FP_StatusWidget_BP_C'");
    	TSubclassOf<UFP_StatusWidget> Widget = Cast<UClass>(StaticLoadObject(UClass::StaticClass(), NULL, *Path.ToString()));
    	UFP_StatusWidget* StatusWidget = CreateWidget<UFP_StatusWidget>(this, Widget);
    	WidgetMap.Add(STATUS, StatusWidget);
    
    	Path = TEXT("WidgetBlueprint'/Game/WidgetBP/FP_Stage_BP.FP_Stage_BP_C'");
    	TSubclassOf<UFP_StageWidget> Widget2 = Cast<UClass>(StaticLoadObject(UClass::StaticClass(), NULL, *Path.ToString()));
    	UFP_StageWidget* StageWidget = CreateWidget<UFP_StageWidget>(this, Widget2);
    	WidgetMap.Add(STAGE, StageWidget);
}

The documentation on garbage collection states that:

“The only container that is safe to have UObject or UObject-derived pointers in is a TArray”

I’d guess that your widget got garbage collected between the time you created it and the time when you tried to call AddtoViewport() for it.

I would suggest replacing the map with an TArray or find some way to store the widget pointer in a class member marked with UPROPERTY to prevent garbage collection.

You are my savior. Thank you!!!