-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
- Loading branch information
1 parent
7755b1f
commit 6b5f767
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); |