I created class, that inherits from MonoBehaviour. Upon instantiating it creating new mesh:
Mesh mesh = new Mesh ();
Then i modifying and using it as sharedMesh for other components.
And everything is ok, but when i Reset () object, mesh always leaking even if i recreated it like this:
I found the core of this problem: I assigned mesh to MeshCollider and MeshFilter, but didn’t release it after reset. I made simple code and in works fine now:
void Reset () {
if (!mesh)
mesh = new Mesh ();
if (GetComponent<MeshCollider> ().sharedMesh)
DestroyImmediate (GetComponent<MeshCollider> ().sharedMesh);
if (GetComponent<MeshFilter> ().sharedMesh)
DestroyImmediate (GetComponent<MeshFilter> ().sharedMesh);
}