in my game, i’m destroying/creating several meshs using the same prefab. But the Vram constently increases, never decreases despite the fact there is always he same number of meshs.
So i wonder :
will the Vram “garbage collects” itself at some point or will it crashs when reaching max value ?
should i re-use old meshs instead of destroying/creating them ?
chunk_transform_intances_array[xc,yc]=Instantiate(chunk_prefab, new Vector3(-x_chunk_render_pos,-y_chunk_render_pos, z_background), Quaternion.identity) as Transform;
Pooling and re-using chunk meshs instead of destroying them solves the problem. It works well because their number is not variable.
But i think i will have the same trouble when i will add items, creatures, etc, whose number will be extremely variable.
If you’re Instantiating new instances of a prefab, they should all be sharing the same meshes, textures, etc, as the prefab, unless you’re explicitly doing ‘new Mesh’ somewhere in your code.
If you’re doing ‘new Mesh’ then you need to match that with ‘Destroy(mesh)’ - destroying the gameObject that uses it is indeed not enough.