in my application I am loading 3D models at runtime. After I have loaded the model, I deleted the imported model properly. I used: Destroy(), Resources.UnloadUnusedAssets() and GC.Collect().
The Profiler confimed that I deleted all textures and meshes properly.
But after deleting, the profiler indicates that the “Mono” memory will not be freed up.
Thanks for your answer. That is not the problem, the meshes were deleted properly from the memory.
The mono memory doesn’t go back at it’s startup value, that’s the problem.
And as Thomas Mountainborn said, the models aren’t taking up their full size in mono.
That is, unless you explicitly access the data in your code on the mono side. For example, if you pull in an array of all the verts of a mesh from the Mesh.vertices property, what this actually does is tell the unity runtime to hand a copy of the vertices over to the mono runtime.
So if you do this multiple times without orphaning the previous arrays first. Then yes, you’ll end up using up a lot of memory for the very large arrays.
I’ve seen much discussion about this in the last few weeks with people trying to manipulate large meshes or images in threads. Because the threads operate in tandem, the arrays of each were getting allocated with one another, and consuming large amounts of memory.
But as long as you do this one mesh after the other. The total memory used for that task will only be that of the largest mesh you pull the data from.