Commit 2ca42c8
authored
repl: keep reference count for
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>process.on('newListener')
1 parent 31a863f commit 2ca42c8Copy full SHA for 2ca42c8
2 files changed
+49-19Lines changed: 49 additions & 19 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- lib
- test/parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+32-19Lines changed: 32 additions & 19 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | | - |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
190 | 218 | |
191 | 219 | |
192 | 220 | |
| ||
327 | 355 | |
328 | 356 | |
329 | 357 | |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | | - |
346 | | - |
347 | | - |
| 358 | + |
| 359 | + |
| 360 | + |
348 | 361 | |
349 | 362 | |
350 | 363 | |
|
Collapse file
test/parallel/test-repl-no-terminal-restore-process-listeners.js
Copy file name to clipboard+17Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
0 commit comments