When setting up an array in OnConstruction, the objects remain in memory when I delete all elements in the array until I close the editor

Hello peeps!

I have an Actor class that has a Tmap array with a UActorComponent as its value.

UPROPERTY(VisibleAnywhere, Category = "Setup")
TMap<int32, UMyActorComponent*> activeActorComponents;

When I create an element I am using

UMyActorComponent* newComp = NewObject<UMyActorComponent>(this, UMyActorComponent::StaticClass());
	if (newComp )
		newComp ->RegisterComponent();
		activeActorComponents.Add(someIndex, newComp );


I add 1000 elements and their names are Comp_0, Comp_1,Comp_2 etc, and when I use this to delete the elements


The elements get removed, but the they still exist in memory.

And when I empty ALL elements and add one again, its name isn’t Comp_0, it’s Comp_1001.

I have been trying things like


and the elements turn to null, but the memory isn’t freed and the names still increment from the last array length.

How do I properly release the Actor components from memory?

Thanks for any tips!