Sequence of GC and unloading assets in Unity3D
c#, garbage-collection, memory-management, unity-game-engine
Solution
There is no difference between these two kinds.
`System.GC.Collect()` will tell .Net collector to collect objects which are managed by mono in the managed heap, while `Resources.UnloadUnusedAssets` deals with assets (textures, sounds and other media) which are put in the native heap. The two method do totally different things, so there is no different which one will be executed first. (As you said, they are both async and you just set a flag to suggest the system it could be a good time to do a collect.)
In fact, it is not so common to call GC collect yourself, except you have a good reason. The GC of system will work in proper time, most of calling for forcing a garbage collect are not so necessary as you think.
If you are wondering more about Unity's memory, you can refer to this blog, which can tell you things in detail.
Problem
Sometimes we need to release useless resources manually in game development. But I'm not sure which is better between ``` System.GC.Collect(); Resources.UnloadUnusedAssets(); ``` and ``` Resources.UnloadUnusedAssets(); System.GC.Collect(); ``` AFAIK, both of them are async operations and there might be no difference. So my question is... - Are there any difference? - If so, which is better?