Stop Leak Mesh and Material

I have written code about editorWindow.First creating new texture ,then refer this texture to material.mainTexture.
if save unity, it clear material maintexture and Showing this Error : Mesh has been leaked 2 times ,Texture2D has been leaked 2 times. I have to drop and down texture to material maintexture .

How can i stop “leaked”?

Inside the Editor you should only use sharedMesh and sharedMaterial / sharedMaterials. material and mesh belong to the runtime-instances. When reading those properties Unity will create a copy of the shared object so it’s independent for this object.

Im my case, I am procedurally generating meshes, so Mesh count starts to reach 300-400 on Save :slight_smile: Nothing to do, and - well, nothing to worry about, from my point of view.