View Issue Details
ID | Project | Category | Date Submitted | Last Update | |
---|---|---|---|---|---|
0000348 | AI War 1 / Classic | Bug - Other | Oct 7, 2010 5:15 pm | Oct 19, 2010 7:19 pm | |
Reporter | Chris_McElligottPark | Assigned To | Chris_McElligottPark | ||
Status | resolved | Resolution | fixed | ||
Product Version | 3.703 | ||||
Summary | 0000348: Memory allocation issues cause frequent GC collections and "hiccup." | ||||
Description | I've added in a row to the F3 debug menu showing garbage collections and the memory used by the GC. Even in the start menu, it's counting up by around 1mb per second, and in the game it's counting up vastly faster. This is leading to the stutter about every 8 seconds that vonduus and a couple of others mentioned. I'm going to look at the graphics rendering stuff to see what I can find, and Keith if you could look at your GUI stuff and see what you can find, that would be great. This problem persists even when the entire RunFrame is commented out (although it's slower), so it doesn't seem to be an issue that is primarily in the game logic itself. | ||||
Tags | No tags attached. | ||||
Internal Weight | |||||
has duplicate | 0000438 | resolved | Chris_McElligottPark | Sound skipping every 8s or 17s |
related to | 0000141 | resolved | Chris_McElligottPark | 3.701 sound distortion and game stutter |
|
Okay, this just gets odder and odder: the memory allocation still happens when I remove huge chunks of the code, basically everything in maincameralogic. Very... odd. |
|
Okay, I now tried it with a super scaled-down project that I created separately for testing the orthographic issue, and it hovers at about 2mb of GC. So SOMETHING is being instantiated beyond the norm here with the AI War project -- investigating... |
|
Okay... I delete ALL of our code, materials, fonts, images, shaders, etc, except for the following: using UnityEngine; using System.Collections; using System.IO; using System; public class MainCameraLogic : MonoBehaviour { void Start () { } void OnEnable() { } void RegisterLogCallback() { } public static MainCameraLogic Instance = null; void OnGUI() { Debug.Log( GC.GetTotalMemory( false ).ToString( "#,##0" ) ); } void FixedUpdate() { } void Update() { } void OnRenderObject() { } } And it STILL DOES it. Must be something wrong with the project itself at this stage, perhaps some sort of artifact of the upgrading. |
|
Okay, after all that, deleting the Library folder makes it do an upgrade one more time, and then it uses only a single MB. Now to back up and try that again with all the rest of the project still in place... |
|
Okay, actually, it's that the Unity editor doesn't clear what's going on between Plays. So you have to completely close the unity editor to see the updates, or do a build every time, either one. So now I'm looking for the culprit with that knowledge in hand... |
|
So this is a more challenging issue than we thought. As it turns out, the GC in Mono 2.6, which is what Unity uses at the moment, just isn't very good or flexible. At least not compared to the .NET version. With all the processing done by AI War, there's a lot of stuff that gets dumped into the GC, but also just using the GUI elements from Unity generates a fair bit of GC load. That's a problem, when it comes to the GC running every 8 seconds and causing a small hiccup. As it turns out, Mono 2.8 has an optional new GC that is absolutely awesome from the look of their graphs, and which would probably solve this problem permanently. The bad news is that Mono 2.8 isn't yet considered fully stable, even though it is out, and the worse news is that Unity is so tightly integrated with Mono that we apparently can't upgrade the version of mono ourselves. The much worse news is that Unity apparently only does mono upgrades at major version releases, which could mean that if that pattern continues it could be the mono 2.6 runtime for another 1-3 years. Yikes. On the slightly brighter side, there are a few things that Keith and I can do to optimize, and we're doing those things, but it's unclear how much benefit will really be seen from that. A lot of the GC load seems to be coming from internal unity components that we can't do anything about, so that's a lot less encouraging. |
|
In 3.710: * We're now taking steps to "stretch" the mono Garbage Collector at game start, so that it won't garbage collect quite so frequently during normal gameplay. This doesn't solve the every-8-second jitter, but it does make it only about every 19 seconds from what we've seen. More info: http://answers.unity3d.com/questions/23223/how-to-stop-sound-from-skipping-during-gc-collection |
|
We gradually resolved this one, and it's pretty darn good compared to what it was, now. On par with the SlimDX version, I'd say, despite the inferior GC here. |
Date Modified | Username | Field | Change |
---|---|---|---|
Oct 7, 2010 5:15 pm | Chris_McElligottPark | New Issue | |
Oct 7, 2010 5:48 pm | Chris_McElligottPark | Note Added: 0000478 | |
Oct 7, 2010 5:48 pm | Chris_McElligottPark | Assigned To | => Chris_McElligottPark |
Oct 7, 2010 5:48 pm | Chris_McElligottPark | Status | new => confirmed |
Oct 7, 2010 6:07 pm | Chris_McElligottPark | Note Added: 0000484 | |
Oct 7, 2010 6:23 pm | Chris_McElligottPark | Note Added: 0000486 | |
Oct 7, 2010 6:26 pm | Chris_McElligottPark | Note Added: 0000488 | |
Oct 7, 2010 6:27 pm | Chris_McElligottPark | Relationship added | related to 0000141 |
Oct 7, 2010 6:55 pm | Chris_McElligottPark | Note Added: 0000494 | |
Oct 8, 2010 3:14 pm | Chris_McElligottPark | Note Added: 0000530 | |
Oct 12, 2010 4:18 pm | Chris_McElligottPark | Relationship added | has duplicate 0000438 |
Oct 12, 2010 4:19 pm | Chris_McElligottPark | Note Added: 0000693 | |
Oct 19, 2010 7:19 pm | Chris_McElligottPark | Note Added: 0001371 | |
Oct 19, 2010 7:19 pm | Chris_McElligottPark | Status | confirmed => resolved |
Oct 19, 2010 7:19 pm | Chris_McElligottPark | Resolution | open => fixed |