-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diagnostics_channel: fix diagnostics channel memory leak
PR-URL: #45633 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
- Loading branch information
1 parent
3fb5c6d
commit 1a47a7b
Showing
4 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Flags: --expose-gc | ||
'use strict'; | ||
|
||
// This test ensures that diagnostic channel references aren't leaked. | ||
|
||
require('../common'); | ||
const { ok } = require('assert'); | ||
|
||
const { subscribe, unsubscribe } = require('diagnostics_channel'); | ||
|
||
function noop() {} | ||
|
||
const heapUsedBefore = process.memoryUsage().heapUsed; | ||
|
||
for (let i = 0; i < 1000; i++) { | ||
subscribe(String(i), noop); | ||
unsubscribe(String(i), noop); | ||
} | ||
|
||
global.gc(); | ||
|
||
const heapUsedAfter = process.memoryUsage().heapUsed; | ||
|
||
ok(heapUsedBefore >= heapUsedAfter); |