From User:
When frequently terminating and re-initializing the FConstraintInstance, there appears to be a leak when cleaning up the disabled joint, which leads to an ever growing list that gets sorted every frame and slowly becomes so massive that performance is destroyed.
What appears to be happening (to paraphrase):
1. the joint is getting queued for deletion on the physics thread
2. the joint is then being disconnected from the capsule body (aka "particle")
3. the disconnect marks the joint as being "disabled"
4. the "FJointConstraintPhysicsProxy::DestroyOnPhysicsThread" function checks "IsValid", which says "no", causing it to never get cleaned up
// GS-BEGIN: Joint constraint leak TOptional<FConstraintInstance> Constraint; virtual void Tick(float DT) override; // GS-END
// GS-BEGIN: Joint constraint leak PrimaryActorTick.bCanEverTick = true; // GS-END
// code placeholder // GS-BEGIN: Joint constraint leak void AJointConstraintLeakCharacter::Tick(float DT) { if (!Constraint.IsSet()) { Constraint = FConstraintInstance{}; Constraint->SetLinearXMotion(ELinearConstraintMotion::LCM_Free); Constraint->SetLinearYMotion(ELinearConstraintMotion::LCM_Free); Constraint->SetLinearZMotion(ELinearConstraintMotion::LCM_Free); Constraint->SetAngularTwistMotion(EAngularConstraintMotion::ACM_Locked); Constraint->SetAngularSwing1Motion(EAngularConstraintMotion::ACM_Locked); Constraint->SetAngularSwing2Motion(EAngularConstraintMotion::ACM_Locked); }Constraint->TermConstraint(); Constraint->SetRefFrame(EConstraintFrame::Frame1, GetCapsuleComponent()->GetComponentTransform()); Constraint->SetRefFrame(EConstraintFrame::Frame2, FTransform::Identity); Constraint->InitConstraint(nullptr, GetCapsuleComponent()->GetBodyInstance(), 1.0f, this); } // GS-END
Expected Results:
The FPS level out and remain steady.
Actual Results:
After a few minutes the FPS will begin to steadily decline.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-147418 in the post.
2 |
Component | UE - Simulation - Physics |
---|---|
Affects Versions | 5.0 |
Target Fix | 5.1 |
Created | Mar 29, 2022 |
---|---|
Resolved | Aug 8, 2022 |
Updated | Aug 17, 2022 |