TArray not properly garbage collected?

I have the following code in my blueprint based on AActor.

UPROPERTY()
UHierarchicalInstancedStaticMeshComponent* MeshComponent;

UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> MeshComponents;

In the first one I store all my instances and GC works fine.
If I divide my instances into separate components that I’ve added to MeshComponents it seems I get no GC, and every new run with “New editor window” causes more memory usage and less fps.

Works: MeshComponent with 100.000 instances

Doesn’t work: TArray of 100 MeshComponents with 1000 instances each.

I hear GC is not yet supported for TArray

The documentation says, TArray is the only container that supports GC:

TArrays have the added benefit of having their elements garbage collected. This assumes that the TArray is marked as a UPROPERTY, and that it stores UObject derived pointers.

Remember that currently, the only container class that can be marked as a UPROPERTY is TArray. This means other container classes cannot be replicated, saved, or have their elements garbage collected for you.

Furthermore, according to that quote and a corresponding code example (see link), UHierarchicalInstancedStaticMeshComponent does not need to be set with UPROPERTY().

The documentation seems to be a little bit outdated, since Steve said that TMap is supported by GC since UE4.9.

To answer my own question.

The problem was that the array wasn’t the only reference to the object once you spawn them since they are attached to the AActor.

I do this when I unload to remove the instances.

TArray<UActorComponent*> components = GetComponentsByClass(UHierarchicalInstancedStaticMeshComponent::StaticClass());
    
for (int32 i = 0; i < components.Num(); i++)
{
    components[i]->DestroyComponent();
}