5.4 GB of RAM used by editor.
So I'm making a 2D game with C# in 64 bit Unity version 5.3 (the same thing happens in 5.4), and Windows task manager is telling me that the editor is using basically all of my free memory (5.4 GB). The editor itself is usable but when I try to test the game it always freezes and crashes everything. Are there any common causes for problems like this?
This only happens with one specific project.
Edit: I've also tried to comment out any scripts that I thought might be causing issues; this solves the issue but I don't know how to fix it. The script contains some large arrays but I'm still surprised that this is enough to fill up all of my memory just by opening the editor.
What's the memory usage right after you restart Unity and load the project - without starting it?
It instantly goes up to about 5.4GB and then creeps up to using all the free memory and then it crashes.
Edit: I've also tried to comment out any scripts that I thought might be causing issues; this solves the issue but I don't know how to fix it.
$$anonymous$$aybe you can narrow it down to one or two scripts. Relevant are probably only the Start() methods, the Update() methods are not called in editor mode.
The script contains some large arrays
Define "large". How many and what kind of elements?
Answer by JotaRata · Mar 05, 2018 at 04:12 PM
Hey, I have solved this by writing an small function which calls Resources.UnloadUnusedAssets() and then call it using a ContextMenu or a MenuItem attribute, using that function clears all unused assets from the RAM and may speed up your Editor a little bit
#if UNITY_EDITOR
[UnityEditor.MenuItem("Assets/Unload Assets")]
static void UnloadAssets()
{
Resources.UnloadUnusedAssets();
}
#endif
Hope it helps.
Your answer
Follow this Question
Related Questions
Have to remake PolygonCollider2D after changing sprite 0 Answers
The game crashes only on some Windows devices 0 Answers
Timeline causes IOS app to crash when adding it, how do i fix this/ 0 Answers
Unity 2019 animator preview window is extremly laggy. 1 Answer
Unity crashes when compiling this script. Where is the problem? 0 Answers