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

Runtime memory allocation optimizations #64

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Metater
Copy link

@Metater Metater commented Jan 8, 2025

Use ArraySegment and buffers allocated at startup to avoid runtime memory allocations.

To any reviewers:

  1. Is zeroing the messagePtr arrays in NextClient.cs and NextServer.cs necessary?
  2. Is the commented out code inside of ProcessMessage() in NextCommon.cs a good way of handling oversize packets or should it stay the way it is?

Thanks!

@Metater
Copy link
Author

Metater commented Jan 11, 2025

By reusing the same buffer for receiving, I created a bug when messages are queued up before the connection fully begins. So all of the queued up messages keep overwriting each other, because they are not processed immediately, as they are normally.

I am working on a fix now where the queued up data is copied to new arrays.

@Metater
Copy link
Author

Metater commented Jan 11, 2025

The issue should be fixed now

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

Successfully merging this pull request may close these issues.

1 participant