gulpjs/vinyl

Potential memory leak

phated opened this issue · 4 comments

In nodejs/readable-stream#202, @mcollina brought up the fact that we might have memory leaks when a Vinyl object with streaming content is cloned. The suggested solution was to delay creation until the streams were needed.

I'm opening this issue so we can discuss further.

I'm not sure if this is similar in concept, but we are using lazystream when constructing Vinyl objects in vinyl-fs's .src() method (https://github.com/gulpjs/vinyl-fs/blob/master/lib/src/get-contents/stream-file.js#L15-L17)

Oh, I didn't know lazystream even existed. You want something slightly different, you want a lazystream that can be cloned and passed around. This it's either a PR there or a new module.
I'll see if I can do a prototype of this.

Here is my take on this issue: https://github.com/mcollina/cloneable-readable.
Please give it a spin, if it helps I need to do one more thing or two regarding error handling.

@mcollina super cool! I'll give it a try soon.