I have subclassed a transform stream. As part of the constructor function I
set up an interval. I need to make sure I clear this interval when the
stream is done, so I don't have a memory leak. Where is the best place to
do this?
I am considering using the end-of-stream module to detect when the stream
instance is finished to trigger the clearTimeout. Is there any edge case I
would miss by doing this?
var eos = require('end-of-stream');
function SomeTransformStream() {
Transform.call(this);
var self = this;
// on constructor, setup timeout
this._timeoutId = setTimeout(function () {
self.doSomething(); // some code I need called
});
// on end of stream destroy self
eos(this, function() {
// is this thorough enough?
clearTimeout(_self.timeoutId);
});
// ... some more stuff
}
Thanks in advance.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/b125149f-6685-49e4-8623-5a63eb61b949%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.