Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ArnimSchinz
Copy link
Contributor

Instead of allocating a new buffer on every file, one can (re)use pooled arrays. There is a good Shared ArrayPool implementation inside System.Buffers, which can be used for this purpose. There should not be a memory-leak in case the buffer is not returned to the pool, so the Dispose() method is enough and no destructor is needed. The array returned by the pool could be larger than the requested size, since the size will always be a power of 2. This is why the buffersize is derived from the length of the returned array. This change only affects 4 lines, I don't know why it shows such a large difference.

@nmangue nmangue merged commit e2c630e into nmangue:master Mar 10, 2024
@nmangue
Copy link
Owner

nmangue commented Mar 10, 2024

Hello Arnim ! Thank you for your contribution

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.

2 participants