repl: keep reference count for `process.on('newListener')` · nodejs/node@2ca42c8 · GitHub
Skip to content

Commit 2ca42c8

Browse files
authored
repl: keep reference count for process.on('newListener')
When investigating a memory leak in one of our applications, we discovered that this listener holds on to a `REPLServer` instance and all heap objects transitively kept alive by it by capturing as part of its closure. It's cleaner to declare the listener outside of the `REPLServer` class and to actually clean it up properly when it is no longer required or meaningful, which is easily achieved through keeping a reference count. PR-URL: #61895 Backport-PR-URL: #63194 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 31a863f commit 2ca42c8

2 files changed

Lines changed: 49 additions & 19 deletions

File tree

lib/repl.js

Lines changed: 32 additions & 19 deletions
Lines changed: 17 additions & 0 deletions

0 commit comments

Comments
 (0)