You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following script which continually creates and closes fs watches can reproduce the leak:
constos=require('os');constfs=require('fs');constpath=require('path');constDIR=path.join(os.tmpdir(),'fs-watch-leak');asyncfunctiontest(){if(!fs.existsSync(DIR))awaitfs.promises.mkdir(DIR);for(leti=1;i<=1000;++i)awaitfs.promises.writeFile(path.join(DIR,`file-${i}.txt`),`${i} test file for watching`);constfiles=awaitfs.promises.readdir(DIR);for(letloop=0;;++loop){constwatches=[];for(constfileoffiles)watches.push(fs.watch(path.join(DIR,file)));for(constwatchofwatches)watch.close();process.stdout.write(JSON.stringify({
loop,files: files.length,
...process.memoryUsage()})+"\n");awaitnewPromise(resolve=>setTimeout(resolve,1000));}}test();
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
Closing the fs watch should free all memory associated with it, including native memory.
What do you see instead?
We are seeing RSS continually rise while heap total and used remains consistent:
Additional information
I've tested this with multiple versions of node (16.20.2 and 20.6.0) and on another version of windows (server 2022), and the leak appears to be present on all.
I've also tested this script on linux and the leak does NOT appear to exist there.
The text was updated successfully, but these errors were encountered:
RedYetiDev
added
fs
Issues and PRs related to the fs subsystem / file system.
windows
Issues and PRs related to the Windows platform.
labels
May 1, 2024
This type of issue is quite hard to debug; qualify as a memory leak is sometimes a bit complicated. If the OS is not requesting that memory back for something else RSS will remain flat. Would you mind to keep this process running after reading/closing those files and see if the RSS lowers again? FWIW I don't a have a windows machine to recreate this
Version
v18.20.2
Platform
Microsoft Windows NT 10.0.22631.0 x64
Subsystem
No response
What steps will reproduce the bug?
The following script which continually creates and closes fs watches can reproduce the leak:
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
Closing the fs watch should free all memory associated with it, including native memory.
What do you see instead?
We are seeing RSS continually rise while heap total and used remains consistent:
Additional information
I've tested this with multiple versions of node (16.20.2 and 20.6.0) and on another version of windows (server 2022), and the leak appears to be present on all.
I've also tested this script on linux and the leak does NOT appear to exist there.
The text was updated successfully, but these errors were encountered: