I'm not sure if it's the way I'm using it or if the spine-unity runtime that is causing the issue but I've noticed while using the profiler that when I destroy a gameobject that has a SkeletonRenderer that it will leak the mesh.
First I made a spine prefab. In code I will use it like so:
GameObject go = (GameObject)Resource.Load("someObject");
SkeletonAnimation skelAnim = go.GetComponent<SkeletonAnimation>();
skelAnim.state.SetAnimation(0, "someAnim", true);
// later when I'm done with it
GameObject.DestroyImmediate(go);
//the mesh data has now leaked.
I ended up adding a Destroy function to the SkeletonRenderer.cs and I call this before GameObject.DestroyImmediate and I no longer get any leaks.
public void Destroy()
{
if (meshFilter != null) meshFilter.sharedMesh = null;
if (mesh != null) DestroyImmediate(mesh);
if (mesh1 != null) DestroyImmediate(mesh1);
if (mesh2 != null) DestroyImmediate(mesh2);
if (renderer != null) renderer.sharedMaterial = null;
mesh = null;
mesh1 = null;
mesh2 = null;
lastVertexCount = 0;
vertices = null;
colors = null;
uvs = null;
sharedMaterials = new Material[0];
submeshMaterials.Clear();
submeshes.Clear();
skeleton = null;
}
I also noticed that in the Reset function you are only destroying mesh and not mesh1 or mesh2, it seems like this is a leak as well because you have "mesh1 = newMesh(); mesh2 = newMesh();" and mesh just looks to point to one of them.