UObjects member fields should be tagged as UPROPERTY so they are properly managed. You can use UPROPERTY only if your containing class is also a UObject. If it is not, then implement the FGCObject interface
Example 1:
class UOwnerClass : public UObject {
public:
UPROPERTY()
UUserWidget* MyWidget;
};
Example 2:
class FOwnerClass : public FGCObject {
public:
virtual void AddReferencedObjects( FReferenceCollector& Collector) override {
Collector.AddReferencedObject(MyWidget);
}
private:
UUserWidget* MyWidget;
};