Potential memory leak in my animation engine

One example: Each time you create unnecessary array objects with this code in setAnimUV().

anim.meshGroup.children[spriteIndex].geometry.faceVertexUvs[0] = []; 
				
// TL , BL , TR
anim.meshGroup.children[spriteIndex].geometry.faceVertexUvs[0].push([
	anim.UVList[spriteIndex][0],
	anim.UVList[spriteIndex][2],
	anim.UVList[spriteIndex][1]
]);

Try to avoid this. Instead, reuse the arrays and just change their content. Your app will allocate less memory and the garbage collection has less work to do.

2 Likes