NoWayOut
NoWayOut

Reputation: 93

Close file after fs.readFile, nulling

Just try nodejs a few days. Should i close somehow files after fs.readFile() ? And if yes how? Should i null or something used and needless variables for better perfomance and memory safe?

Thanks.

Upvotes: 8

Views: 18977

Answers (1)

dark_ruby
dark_ruby

Reputation: 7866

to close a file descriptor use this call

fs.close(fd, callback)

however since you're using fs.readFile which reads the entire file - it deals with opening and closing file for you, so you don't need to close anything

Upvotes: 19

Related Questions