Problem with TMap Unreal

Hello everyone, I have a problem with the TMap structure. my project is pacman game. Briefly I create a TMap with key a TVector2D and value pointer to my cookie actor.

Every time I move with Pacman I check if my structure contains the cookie with FindRef.
This is where the problems begin: sometimes after 10 cookies Unreal crashes…sometimes after 50 cookies Unreal crashes… With debugging the problem is that it finds a null structure. Structure should be nothing. why does it return a null pointer?

A thousand thanks

Sounds like the pointer is being garbage collected.

You using UPROPRTY() macro with your TMap?
e.g.

UPROPERTY()
TMap<USomePointer*, FVector> SomePointerVectorMap;

Hi Kris,
I have solved after that i remove one function call in game instance. This function is connected to widget in the editor.
Is it possible for a widget to signal an error in an array structure in debug?
problem solved but i’m confused