-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Go - reuse buffers #85
Comments
There is another option to solve the original problem of avoiding too much garbage collection: The ability to reuse a builder for other serializations. To do this, there would need to be a way re-initialize the internals, without re-creating objects, e.g. clearing the vtables without removing the allocated capacity. |
I am strongly in favor of something like this. Would you like to to try making a pull request? |
Yeah, the C++ buffers are already reusable, see FlatBufferBuilder::Clear(). |
It looks like #165 has code for this. |
Since #165 is merged can't this issue be closed? |
Looks like it.. @rw ? |
Yeah,
|
Closing since this is fixed by #165. |
With Go being garbage collected, it is a bad idea to constantly create byte buffers from scratch.
Rather than creating new buffers, there should be a mechanism to reuse buffers.
A simple way to do so is to expose public variables of type func that are used for buffer creation, and if possible also a variable of type func that releases the buffer (back into the pool).
The default assignments to the variables can use the existing implementation (create buffer from scratch), but any client that wishes to override the variable with a function that uses a buffer pool.
The text was updated successfully, but these errors were encountered: