UE-199993 SkeletalMeshComponent in dedicated server causes memory leak

USkinnedMeshComponent::BoneTransformUpdateMethodQueue array keeps growing and never clear.


https://issues.unrealengine.com/issue/UE-199993

I keep running the DS server, and the array USkinnedMeshComponent::BoneTransformUpdateMethodQueue keeps adding elements continuously, but during the runtime of the server, the elements are not cleared, resulting in a continuous growth of memory when the server is turned on. Although the growth is slow, after running the server for about a month, a memory warning occurs.



My issue was discovered in version 5.3, and UE-199993 indicates that this issue exists in both 5.2 and 5.3. The relevant code was modified in the commit with CommitId: ee14c94 in version 5.4, but the leakage issue still persists.

I created a third-person template project, placed the character into the map, and set the “Visibility Based Anim Tick Option” of the Mesh Component to “Always Tick Pose and Refresh Bones”. After baking the server, I compiled and ran the server in C++. At this point, it was observed that the “BoneTransformUpdateMethodQueue” array kept growing continuously.




If your blueprint inherits from ACharacter, then the VisibilityBasedAnimTickOption of the SkeletalMeshComponent defaults to AlwaysTickPose. However, if you manually add a SkeletalMeshComponent, the default setting is AlwaysTickPoseAndRefreshBones. Nevertheless, the engine allows you to change the default settings in an ini file by adding the following code to DefaultEngine.ini:

After doing this, I resolved the memory leak issue. Below are the data on memory allocation and deallocation for Animation after running for 20 minutes:

However, this should still be considered a bug in the engine, even though many projects perform performance optimizations on animations to avoid using AlwaysTickPoseAndRefreshBones .