Download

Procedural mesh memory usage explodes with large data

Hi,
I’m developing a model loader plugin in my game that allows runtime import of GLTF models. Since the models are usually not available beforehand, I’m using procedural meshes to create the model. The smaller of these models has upwards of 20,000,000 (million!) vertices, normals, colors, etc. The number of such meshes I create is upwards of 15,000. What I notice in such cases is the massive increase in memory (~1GB) consumption as I start creating these Procedural Meshes and rendering them. I’ve tested the plugin separately on a sample project and still get the same results. If I turn off the mesh generation, there is no increase in memory (as expected). I’ve isolated the issue at “CreateMeshSection_LinearColor” method which actually creates the mesh.

So, is there some kind of performance drop that is to be expected when using a large number of procedural meshes? I couldn’t find any documentation regarding this and any help in this matter is much appreciated.

An unrelated (to topic) but related question. I’m not able to “free” the memory associated with these meshes after the model has been removed unless the game is restarted. I imagine the problem here is that there are still some references to the mesh sections that persist. Is there some sort of cache used by the renderer that I need to manually clear?

If there is any extra info/clarity required, feel free to ask.

Thanks,
Prash