free up mono memory

Hello,

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.

Here: http://docs.unity3d.com/Manual/MobileProfiling.html (under memory/mono memory)
It says that it’s normal that the Mono memory will only be relocated if the application will be closed.

My question:

Is there any way to free up the Mono memory while the game is running? Maybe with the new MonoDevelop 5.9 Version? Or is there any other workaround?

regards

Mono memory does not contain meshes, so its amount won’t be reduced when unloading meshes.

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.

regards

Nope, that’s the way the Mono runtime works.

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.

Thanks for your answer!
So in order to free the mono memory (or most of it), I should destroy all arrays etc. with their contet?

no, you can’t free up allocated memory.

What you can do is avoid allocating too much memory. Because that memory will be reused.

Basically don’t store a lot of memory simultaneously, but instead do so one after the other in time.

Ah okay, thank you very much!