Are you doing this during level load or every frame? If the former then don’t worry about it. If it’s the latter then you could/should preallocate these things before game play starts.
But yes, you’re allocating memory when you create an asset. Nothing you can do about it. Garbage is only created when you stop using it, however, and then it will eventually get collected. The collection is actually the "bad’ part that can cause stuttering.
I have a tool that creates walls and floors every 2x2m where you want them and then after a click it gets combined into one big mesh. Can I somehow store it temporarily after it’s all done and then lets say run a coroutine to free pieces of it one by one (if there are actual “pieces”) every frame until it’s empty? If I can somehow chop the big process into smaller pieces I can deal with it somehow but I cant find if it’s possible or what it would even be, anywhere.
I’d be happy to do that because even though I am not combining those meshes every frame I cant do it on level load because it’s dependant on user input (actual building the grid and walls in it)
I guess I will try to find another way to do this because right now it’s a no go.
Update: It was a bad idea to be using asset creation in the first place since it won’t be present in the game itself. Storing mesh.vertices, mesh.uv and mesh.triangles and then recreating the mesh at start the way to go for me.