Skip to content
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

Closed
gamemachine opened this issue Jan 28, 2018 · 2 comments
Closed

Memory allocation #9

gamemachine opened this issue Jan 28, 2018 · 2 comments

Comments

@gamemachine
Copy link

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.

@roy-t
Copy link
Owner

roy-t commented Jan 28, 2018

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?

@gamemachine
Copy link
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants