I’ve got 20 agents in my scene (just for reference) and in the profiler it is saying that on an average frame, I’m generating 146KB of GC Alloc every frame coming from BehaviourTree.OnGraphUpdate(). The AI that I’ve created isn’t overly complex, about 5% of what I want the final AI to be capable of.
As you can imagine this is pretty heavy, about 20ms on the CPU which I definitely cannot have. I also let the game play in the editor for a few minutes and it had maxed out my 32GB of ram. (I’m in Unity 5 Beta 18)
I wanted to check to see if anyone else is experiencing this problem? Or if it was a bug that needed to be reported.
I’ve narrowed it down to “Array.Resize()” as you can see in the attached image of a deep profile. This is with 10 agents, hence the 60-70KB of GB Alloc instead of the higher numbers mentioned above.
Does anyone know what is causing this or how to avoid it?
This is definetely wrong in my part, or in other words it’s a bug :).
I’ve tracked down the issue and is basicaly because of the CheckField. It also happens on CheckProperty.
Please give me an email and I will send to you the fixed files once I’ve fixed it tomorrow first thing.
Thanks a lot for posting it and the details provided.
I switched them all to properties and it definitely is better, about 30% better in terms of GC Alloc. But I’m still generating hundreds of KB every frame.