Memory not being cleared when editor only actor deleted.

This is strange…

So the OnConstruction() function gets run twice when the actor is dragged into a level. Once for the preview actor and once for the real actor.

I had to add:



if (!IsTemplate(RF_Transient))
{
MyFunc(MyStructArray);
}


This then only runs MyFunc on the real actors OnConstruction(). This causes the ram to use only half of what it was using because the preview OnConstruction is not running.

Second problem (RAM not freed):

In the destructor of the actor the MyStructArray variable which is a TArray of FMyStruct is stating that the array is empty even though the for…loop is running correctly to add the data and the RAM is being used by the actor. This RAM is then never freed when the actor is deleted.

If I add UPROPERTY() to the


TArray<FMyStruct> MyStructArray;

then the memory consumption actually goes up when you delete the actor and the existing memory is never freed.

Please, can anyone help?