Download

TArray<UHierarchicalInstancedStaticMeshComponent> not properly garbage collected?

I have the following code.


UPROPERTY()
UHierarchicalInstancedStaticMeshComponent* MeshComponent;

and


UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> MeshComponents;

In the first one I store all my instances in the same MeshComponent, and GC works fine.
If I divide my instances into separate components that I’ve added to MeshComponents I seem to 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.