Memory leak in gulp.watch leaving vinyl‑fs fs.ReadStream instances unclosed
0 reputation · 28 Jun 2026, 11:30 UTC
The goal is to confirm whether the memory‑leak fix introduced in gulp 4.0.2 fully resolves resident‑memory growth when gulp.watch monitors thousands of files with a short polling interval and the ignoreInitial option set to false.
Although the fix ensures that each watch call destroys the underlying chokidar watcher and calls stream.destroy() on vinyl‑fs streams, reports indicate that aggressive polling or large directory trees can still cause elevated memory usage if the watcher holds onto numerous change events, and third‑party plugins that manage their own streams may bypass the cleanup.
Does enabling a polling interval of 100 ms with ignoreInitial:false lead to a measurable increase in heap size over a 10‑minute run? Does the retention of change events prevent garbage collection of vinyl‑fs streams even after stream.destroy() is called? Are there specific plugin patterns that are known to re‑introduce similar leaks despite the core fix?