fs.write and buffers

418 views
Skip to first unread message

khs4473

unread,
Oct 9, 2012, 10:34:54 AM10/9/12
to nod...@googlegroups.com
At what point is it safe to reuse a buffer that is submitted to fs.write?  Clearly when the callback is executed, but the buffer appears to be free on nextTick as well...

Kevin

Isaac Schlueter

unread,
Oct 9, 2012, 2:57:06 PM10/9/12
to nod...@googlegroups.com
It is not safe to re-use a buffer once it's passed to an async method,
and before the callback. In the case of stream.write() it's not safe
to assume that it's *ever* ok to re-use it.

Memory is cheap. If you don't know for sure that it's your
bottleneck, just let it go out of scope and get collected.
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
Reply all
Reply to author
Forward
0 new messages