- Home /
Why does Unity crash? (and other programs in general)
Hey people!
Do you know why Unity eventually crashes when I am processing my data through massive recursions in a separate thread? I am passing a function into a Thread object and Start it.
The thing is, those recursions are really massive, up to 7 million cycles in about 2 minutes with my cpu. I have 8 GB ram core i7.
question:
What's the cause of a program's crash after 3 minutes? If I reduce the cycles, and the recursion depth, it executes just fine. Does it always happen when program runs out of memory? If so, is there a way to increase it's memory, to give it more space, using c#?
Thank you very much!
Answer by Bunny83 · Jan 05, 2014 at 02:29 AM
Well, it seems mono has a hard limit(~4MB) on the stacksize which can't be increased without changing the monoruntime itself. Since Unity uses it's own build of mono you can't really change it. It's hard to say when your program runs out of stack. It depends entirely on your recursion depth and on the stackframe size of one recursion. It might also depend on how your recursion is implemented. If done the right way the compiler might optimise the recursive calls into tail calls which wouldn't require any additional memory. However i don't know if the C# compiler that Unity uses does such optimisations.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Need to use HDD instead of RAM 1 Answer
Distribute terrain in zones 3 Answers
How to increase the Call Stack Size in Unity? 0 Answers
A simple recursion leads to crash 1 Answer