- Home /
Fatal error in GC: too many root sets
What does this mean!?
Haha, thanks, Elliot Bonneville.
Answer by DaveA · Mar 18, 2011 at 04:26 AM
Ah, thanks for the link. After having read the thread, it seems that this bug is caused by restarting the Editor Player too many times. For example, if you were making small tweaks to something and checking how it looked, dozens of times. I'm glad to hear it's not something related to my project. :)
refreshing... 1 thumb up, that one scared the wheels off me land rovuh...
Nice to find a quick&ready answer t.y.
I don't know what causes it, but it's nothing to do with how many times you restart the editor - I just had it happen within 5 $$anonymous$$utes of restarting my machine.
@SPECS: [WIN7 Pro, 4Gig, Duo2.66, x86-on-64bit] [Unity 3.4.0f5{latest patch not installed}] [$$anonymous$$onoDevelop 2.4.2] (was on old original code editor when error popped up) ---
@Simon: can you provide OS, UnityVersion, Code Editor
@ALL: $$anonymous$$y project has many sections. I have been away from the section that got this error and I never got the error anymore. I will report when I am back in the culprit section for a month or so.
...we should all keep in $$anonymous$$d that versions and levels of systems are moving so fast we may never know the answer... just as long as the error vanishes.
Answer by Clausman · Oct 13, 2011 at 03:55 PM
No idea if this can shine any more light, but I can produce the error in about 10 second by spawning lots of small computation threads. I am guessing at about thread 100 or so the error gets thrown. Each thread calculates a single line or code and another one is created immediately after the previous one finishes. Given this it is most surely an issue with resource allocation. In my case I am 99% sure I am overloading the garbage collector by creating way more threads than is sane.
Search around for "garbage collection too many root sets" MSDN has a mildly helpful article about best practices and explains root sets decently well.
Answer by Clausman · Oct 13, 2011 at 04:10 PM
I produced the same error creating far too many short-lived threads. It is definitely a garbage collector error. You are only allowed a set number of root elements and the error is basically saying that the storage for root elements just tried to overflow. if you search for "garbage collector too many root sets" you can learn some more. However, since I don't believe we get access to the compiler flags in Unity there isn't much you can do besides try to make your code more 'GC friendly.' MSDN has an okay article explaining gc practices and root sets which you may want to skim. Otherwise avoid recursion and local declarations if possible; oh and don't create 100+ threads that only do one line of code each :)