Problem:
- We have blueprint with SplineComponent which in ConstructScript spawning SplineMeshComponent (with StaticMesh with colliders)
When place blueprint at scene - we have 100,675 objects
- Trying to move last point of the SplineComponent to produce/reduce components
After some seconds we get a 103,981 object
- If add GarbageCollect at Construction script - all zombie objects will be collected but generegate huge lags when moving point
†
Whats going on:
- On move spline points - PostEditMove event rerun ConstructionScript and generate new segmnents
- When ConstructionScript add components - AddComponent call RegisterComponent which call USplineMeshComponent::OnCreatePhysicsState() . This function start create collision as BodySetup
- Before rerun ConstrctionScript (function AActor::RerunConstructionScripts()) - PostEditMove calling DestroyConstructedComponents() which clearing components!
- When function DestroyConstructedComponents() call DestroyComponent() - USplineMeshComponent has not overrided function DestroyComponent() or OnDestroy() or some else and not call USplineMeshComponent::DestroyBodySetup() which provide zombie BodySetup
†
Confirmation:
Coding some c++ script with UObject iterator which iterate all objects and get theirs classes and counting
Before - 380 instaces of UBodytSetup
After - 2444 instances of UBodySetup