-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory allocation #9
Comments
Hmm, the only allocations per frame are from making searchNodes, which are short-lived (g0) objects. I haven't had any problems. But we could move to zero allocations by using a pool for those objects. What do you think? Are you having real problems? |
ToArray on the Stack allocates, as does just allocating a Stack so you allocate two collections there on every path. IEnumerable allocates also. I'm using Unity which uses boehm. It's common practice to have zero gc in the Update loop on Unity because of that since short lived can easily end up in a stop the world collection. No big deal I needed to customize it anyways for concurrent pathfinding also. I'm working with up to 100 agents pathfinding every couple of seconds. Which is too much for the main thread. I also converted it to use Unity Vector2Int instead of positon so I didn't need multiple position lists. Plus I just have the pathfinding specific stuff since Unity doesn't support .NET Standard (beta release does but not on that). |
I like the code overall, but it's not usable in games as is because it's so heavy with allocations.
Lots of games have a zero heap allocation policy for pathfinding.
The text was updated successfully, but these errors were encountered: