Vram increases

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 ?

There is garbage collection, and if you are making a game with a lot of creating and destroying, you will probably be better off pooling gameObjects.

VRAM is not garbage-collected.

Can you show how you’re destroying and creating the meshes?

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;
Destroy(chunk_transform_intances_array[(int)v2.x,(int)v2.y].gameObject);

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.

That’s GameObjects, not meshes.

well, ok.
Destroying the gameobject seems to be not enough.

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.