Unity3d crash when I don't use debug log

Hello everyone,

Here’s a tough one. In my application, I have a part where I need to add dozens and dozens of components to a GameObject. This is a really huge action to complete and I knew the application would crash.

So I did use Debug.Log to be sure where it would crash :

int i = 0;
foreach(string typeToAdd in typesToAdd){
Debug.Log('#'+i+' '+typeToAdd);
/*Add component to the GameObject, depending on what we have in typeToAdd*/
}

Pretty simple. Of course, my code would crash because the list of Components to add was huge. I did some optimization by decreasing the size of the list. I divided this big list into some more little lists that are used to add Components during multiple frames instead of one big list of Components to add in only one frame.

And it worked ! My Application doesn’t crash anymore. Great. So I though I could remove the Debug.Log to clean up my console. And I tested again. BAM! The Application crash again.

When I leave the Debug.Log, the Application works well. When I comment this line, the Application is crashing again.

Any idea on where it comes from? Thank you guys.

Are you able to create a minimal project that reproduces this issue? Our developers should investigate that behaviour. Please submit a bug report as described here: