I always use background threads to do some certain things.
When I stop my unity3d, I find that freeing memory isn’t done during the debugging. Why isn’t freeing memory be done? How do I free the memory?
1 Answer
1Have you tried Dispose()?
timer.Dispose();
but.... When I stoped the u3dEditor. You know I can't do that:'timer.dispose()' And, when I stoped u3dEditor I saw the run of log is printting, if I used the Timer in my code. I mean the log of "Console view"
– c_c_z_ztimer.Stop() maybe? or timer.enabled = false
– luckruns0utIf you need to detect when your application is about to quit so you can call timer.Dispose(), put the following method in the script that is using the timer. C# void OnApplicationQuit() { timer.Dispose(); } JavaScript function OnApplicationQuit() { timer.Dispose(); }
– whebertThank you. Are the 'OnApplicationQuit()' only for UnityEditer ?
– c_c_z_zNo, OnApplicationQuit will be called in standalone, web player, or in the Editor when you stop play mode. See [reference][1]. [1]: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnApplicationQuit.html
– whebert