Pharan написавI wish I could help but I don't have a pro license. Does the profiler have the ability to tell which specific things/methods/lines are causing heap allocations?
Unfortunately no...but it should be showing the allocation is from the main loop of the LateUpdate method.
After some digging, we found out that this only happens on animation using Free-Form Deformation feature. For animations not using this feature, we're not seeing any heap allocations. One of my wild guess - could it be count of vertices keep changing on Free-Form Deformation animation? (shown as attachments)
And after I added some "Debug.Log" statements to SkeletonRenderer.LateUpdate method, I found that the allocation is happening here for SkinnedMeshAttachment:
if (tempVertices.Length < meshVertexCount) {
Debug.Log("[SkinnedMeshAttachment] allocatioin temp vertices");
tempVertices = new float[meshVertexCount];
}
The output of this debug log is also attached.
Please help with this. I think this should be a common problem for Unity runtime whenever Free-Form Deformation is used.
Some follow-up...I did some temporary change myself and resolved the memory allocation!
This is what I did: 😃
if (tempVertices.Length < meshVertexCount) {
tempVertices = new float[meshVertexCount];
// We should remember and reuse the new tempVertices array to avoid future allocation
this.tempVertices = tempVertices;
}
Please help review whether this change will have any side effect.