-
Notifications
You must be signed in to change notification settings - Fork 126
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
Create Local handle for new Buffers to avoid GC #20
Conversation
👍 |
Wow, forgot how ugly the Buffer API is in 0.10. Also, Buffer::New(size) doesn't zero fill the memory. So it's possible to have random bytes wandering around in the allocated memory. Don't know the code that we'll, but are you writing to the entire Buffer or just part of it. |
@rvagg I'm pretty sure |
it's a weak |
I can confirm that this patch fixes the corruption problem I saw in #19, at least it made it through 10M cycles whereas before I was seeing corruption after only a few thousand. I know nothing about the memory-lifetime tools here, but memory usage appears stable, so I don't think it's keeping the memory around forever. |
the addition shouldn't have any impact on memory: |
Create Local handle for new Buffers to avoid GC
Thank you for the fix. this bug was hunting me for some time now. |
fixes #19
The lack of a
Local
handle inside theHandleScope
where the newBuffer
objects are being created means that the GC can kick in while you're still working on them and clean up the handles that were originally created for them. This change introduces explicit handles each time youBuffer::New()
which will automatically be assigned to theHandleScope
in use.