Before updating to Windows 10 you may need to return your Pro license. More information here

Fatal error in GC: too many root sets

What does this mean!?

Haha, thanks, Elliot Bonneville.

more ▼

asked Mar 18, 2011 at 03:22 AM

avatar image

6.5k 253 231 304

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first
more ▼

answered Mar 18, 2011 at 04:26 AM

avatar image

34.7k 420 360 561

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. :)

Mar 18, 2011 at 01:03 PM e.bonneville

Ah so that's the reason. Still not fixed, btw..

Jun 09, 2011 at 03:05 PM Joshua

refreshing... 1 thumb up, that one scared the wheels off me land rovuh...
Nice to find a quick&ready answer t.y.

Jun 27, 2011 at 06:52 AM dingben

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 minutes of restarting my machine.

Sep 30, 2011 at 09:16 AM SimonW

@SPECS: [WIN7 Pro, 4Gig, Duo2.66, x86-on-64bit] [Unity 3.4.0f5{latest patch not installed}] [MonoDevelop 2.4.2] (was on old original code editor when error popped up) ---

@Simon: can you provide OS, UnityVersion, Code Editor

@ALL: My 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 mind that versions and levels of systems are moving so fast we may never know the answer... just as long as the error vanishes.

Oct 05, 2011 at 05:37 PM dingben
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Oct 13, 2011 at 03:55 PM

avatar image


(comments are locked)
10|3000 characters needed characters left

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 :)

more ▼

answered Oct 13, 2011 at 04:10 PM

avatar image


(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Mar 18, 2011 at 03:22 AM

Seen: 7583 times

Last Updated: Oct 13, 2011 at 04:10 PM