I need optimize this GC allocation

Hi, please, what is this process? how i can improve the performance and GC allocation of this process, i have only 100 units in my game that update his destination position each 5 seconds, and each time that this happens, appears that GC allocation spike, there is my code:

image

image

Thanks so much!

Hi

That comes from when the agents recalculate their paths. Most allocations should be pooled, though, so after the 3rd or so time it happens, the allocations should be much smaller. Is that not what you are seeing?

Hi @aron_granberg , i am not seeing that, each spike use approximately the same ~ GC calls,

i am try now, and after 10 minutes with the same 100 units, still the quantity.

Do you think you could use deep profiling to see which allocation is happening?

There is video that show us the depth profile, I see that there is some string operations that causes that GC allocations.

Video depth profile

Have you by any chance enabled ASTAR_POOL_DEBUG within the Optimizations tab on the A* component?

I disable Astar_pool_Debug and all allocations form string operations was removed, now the allocation is in:


Any way to handle this?

Thanks so much Aron

Great!

That remaining allocation is for when growing the total number of rvo agents. It should disappear once you reach a stable number of agents in the scene.

And this item is the same, is normally have 22k of calls in some items in this list?

I want be sure that i implement the most optimized IA code, because is a mobile game then i need a high performance :smiley:

I’d like to point out that the allocation has changed from ~1.5 megabytes to ~1.5 kilobytes, a factor of 1000 less.

Are you sure you only have 100 units? From that log, I would expect you to have 5619 units in the scene.

You are right, i miss a condition in my code that creates a lot of units, thanks so much, all is clear!

1 Like