Leaking memory when destroying gameobjects.

I am currently playing around with voxel world generation and I am leaking a ton of memory when destroying chunks. I’m positive that everything else works. I had no problems back when I was moving the chunks and giving them new values i had no memory leaks. now that i’m spawning and destroying chunks i’m getting problems. Can someone help?

function testMem() 
{	
	if(chunkTest!=null) 
		{
			chunkTest.GetComponent(MeshFilter).mesh = null; 
			chunkTest.GetComponent(MeshCollider).sharedMesh = null; 
			Destroy(chunkTest.gameObject); 
			chunkTest=null;
			testPos += chunkSize.x;
			
		}
	chunkTest = Instantiate (prefab, Vector3(0, 0, 0), Quaternion.identity);
	generateChunk(Vector3(testPos,0,0),chunkTest.GetComponent(MeshFilter).mesh);
}

NOTE: I call this in Update(). the actual code is much more complex but in an effort to make things easier to read i have made a simplified test and only copied the relevent parts.

It would be better to reuse objects instead of instantiating/destroying all the time.

–Eric

it probably would be however i solved my issues by unloading unused assets. might make some changes later to reuse assets but for now this seems to work and run pretty smoothly too.