I have a game that cycle between maps each round, some of which contain terrain. I am experiencing an issue though where the memory from Terrain and TerrainRegion objects is never cleared. I am not sure what causes this. Even if I destroy the TerrainRegions, the place memory never actually goes down and instead it shifts from Terrain Voxels to Untracked Memory.
I have created a test place where you can see this yourself. Without the TerrainRegions, the published place memory should be around 300MB. With them, it’s around 1000MB (700 MB in TerrainVoxels). When you hit the “Destroy Terrain Templates”, it destroys the folder with those objects in it which instead just shifts the memory to Untracked Memory which never seems to be garbage collected. Can someone check out the place and see if there’s anything wrong?
I am not sure what is causing this as the TerrainRegions are being deleted but the memory from them is still being held onto. I am not sure if this is a bug or just improper use of the Terrain object.
This is a known bug in Roblox, here’s the discussion on the Developer Forum
Do you just want the memory to clear properly when the Templates folder is destroyed? Is that the only issue here? Or is there more to it than that?
Edit: I think I found the issue but I think it’s beyond your control. Get back to me when you can so I can be certain, then I’ll probably file a bug report for you. Same goes to @Amir2223 since you seem to be working on the same project.
That is the main issue, but I would also like the memory to go down when the Terrain:Clear() is called as well. I used to be able to get it reading 300MB default even with the TerrainRegions in server storage, but now it’s defaulting to 900MB even without loading one into the workspace. I’m wondering if Terrain:Clear() just fills the voxels with air and doesn’t actually bother combining neighbors and optimizing, leaving you with a the map essentially still loaded in memory but just filled with Air voxels. 900MB from 3 inactive TerrainRegions seems a bit much
causes a memory leak where none of the cloned regions are ever released. This strangely doesn’t happen in Studio unless you click Play. By which I mean you can’t replicate this from the command bar.
I’ll go ahead and file a bug report since I have access to that. Can you do me a favor and leave that place uncopylocked so the people looking into the bug can have a quick example?