console.log entries in Node.js does not get garbage collected
github.com
github.com
I noticed that the default stream for console.log in node.js does not get garbage collected, and raised an issue about it in the github node org, where a node dev has acknowledged the behavior.
He provided a link to a larger thread where this is being discussed, but it seems it's been in discussion since 2016.
One possible solution around this is to write log entries to a file instead of using the default stream.
Via bnoordhuis (Ben Noordhuis - node.js dev):
I see you posted this over at https://www.reddit.com/r/node/comments/8s2y7b/til_consolelog... but your summary there is wrong. You should update it because it's going to mislead others.
The state of things:
A connected inspector client will cause console.log() to buffer a bounded number of messages (currently 1,000.)
Libuv can buffer messages when you print faster than the sink (tty, pipe, file, etc.) can consume them. That's something you can fix by pacing your writes.
[1] https://tech.datawallet.com/posts/weekly-update-2018-06-01/
https://www.reddit.com/r/node/comments/8s2y7b/til_consolelog...
I would not recommend console.log for production anyway