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

Know ahead of time whether .reserve will reallocate #602

Open
yshui opened this issue Feb 25, 2023 · 0 comments
Open

Know ahead of time whether .reserve will reallocate #602

yshui opened this issue Feb 25, 2023 · 0 comments

Comments

@yshui
Copy link

yshui commented Feb 25, 2023

.reserve employs some heuristics, which are subject to change, to determine whether it's going to move the data or reallocate. A user concerned with memory usage might want to do something, like flushing out the buffer to I/O, before BytesMut gives up and grows the allocation.

Right now there seems to be no way to achieve this. Maybe there could be a .compact method which is like .reserve minus reallocation, and returns whether it could expand the available space.

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

1 participant