- Home /
sharedmesh using memory ?
Hello,
Im have a little question regarding sharedmesh's memory use.
Situation : Im making a grid-base map system, quite like Dwarf Fortress, except 3D. The way I do it is as follows : 1) Generate terrain data for the map, 2) Procedurally create mesh chunks - each chunk cover a small area of a level - and keep mesh chunks in memory, 3) When a level must be displayed, I assign the chunk meshes to existing gameobjects using sharedMesh.
What happens : The first time a chunk mesh is applied to a gameobject renderer, I see a memory usage increase (arround 12MB).
I assumed that since the mesh already exists in memory, aplying it as a sharedMesh should not increase memory usage. Am I wrong or did I do somthing inappropriate ?
Code called when a level must be shown :
for (x = 0; x < chX; x ++) { for (z = 0; z < chZ; z ++) { for (y = 0; y < ml.showLevelBelow; y ++) { if (lvl - y >= 0) { chunkDisplays[x,y,z].active = true; chunkDisplays[x,y,z].GetComponent. ().sharedMesh = chunksMeshes[x,lvl - y,z]; } else { chunkDisplays[x,y,z].active = false; } } } }
Your answer
![](https://koobas.hobune.stream/wayback/20220613142434im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Strange behavior when adding generated sharedMesh to MeshCollider 0 Answers
Sharing a generated mesh between multiple game objects 2 Answers
Build Fails Due To Unity Crash: Out Of Memory 2 Answers
Memory Managmenet 1 Answer
Unity memory run out issue 0 Answers