Memory not freed using FRunnable and TArray

Can anyone answer this question for me?

With a struct like this:


struct FMyFloatArrayStruct
{
public:
    TArray<float> FloatArray;
};

A defined array in the actors header like this:


TArray<FMyFloatArrayStruct> TestStructArray;

An actor Destroyed() function like this:


void AMyActor:Destroyed()
{
    TestStructArray.Empty();
}

Running this code on the actors MAIN THREAD clears out all of the RAM when the actor is deleted in the level editor window:


TestStructArray.Empty();
TestStructArray.Init(FMyFloatArrayStruct(), 300000000);

for (int32 Index = 0; Index < 300000000; Index++)
{
    FMyFloatArrayStruct* Struct1 = &TestStructArray[Index];
    Struct1->FloatArray.Push(FMath::Rand());
    Struct1 = nullptr;
}

…but this code run using an ASYNC TASK, does NOT clear out all of its RAM when the actor is deleted in the level editor window:


AsyncTask(ENamedThreads::AnyBackgroundThreadNormalTask, &]()
{
   TestStructArray.Empty();
   TestStructArray.Init(FMyFloatArrayStruct(), 300000000);

   for (int32 Index = 0; Index < 300000000; Index++)
   {
      FMyFloatArrayStruct* Struct1 = &TestStructArray[Index];
      Struct1->FloatArray.Push(FMath::Rand());
      Struct1 = nullptr;
   }
});

My RAM for both functions goes up to 9800Mb when fully finished.

The RAM for the MAIN THREAD version goes back down to 600Mb after the actor is deleted.
The RAM for the ASYNC TASK version goes down to 5200Mb after the actor is deleted.

Why is there a difference?