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

Request to allocate chunk over maxSize shouldn't panic #1

Closed
arodland opened this issue Oct 20, 2015 · 1 comment
Closed

Request to allocate chunk over maxSize shouldn't panic #1

arodland opened this issue Oct 20, 2015 · 1 comment

Comments

@arodland
Copy link

What I think would be really wonderful would be if Allocate is called with a size bigger than maxSize, it should just make it and return it, never returning it to the pool (and obviously never looking for it in the pool).

I have an app that needs to buffer requests, most of which are a few MB, but occasionally one is a GB or more. I don't want to set maxSize so large and allow a GB buffer to go back on the pool, but it would be great if I could set maxSize to 10MB, let most of the requests be served by the pool, and take the occasional GC hit when a giant one comes along.

If you don't like this idea, then it would be nice to make maxSize public or add a getter for it, so that I can do an if size > pool.MaxSize in my own code without having to store the max size separately. The last thing I want is to have to recover from a panic.

@thejerf
Copy link
Owner

thejerf commented Oct 22, 2015

Thank you for the use case. Much of why it is a panic is that I couldn't figure out what the use case would be.

It seems to me the correct answer is both; it should be accessible, and it should go ahead and make larger buffers and return them without tracking. I'll get that in the next day or two. (Or you can submit a fix, if you've got one in hand. No pressure, just if you already have one.)

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