| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 90b5ed1 commit 54a29ee
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,9 +5,6 @@ prefix parallel | |||
| 5 | 5 | # sample-test : PASS,FLAKY | |
| 6 | 6 | ||
| 7 | 7 | [true] # This section applies to all platforms | |
| 8 | - # https://github.com/nodejs/node/pull/50327 | ||
| 9 | - # Currently there's no reliable way to test it. | ||
| 10 | - test-diagnostics-channel-memory-leak: SKIP | ||
| 11 | 8 | ||
| 12 | 9 | [$system==win32] | |
| 13 | 10 | # https://github.com/nodejs/node/issues/41206 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,24 +1,22 @@ | |||
| 1 | - // Flags: --expose-gc | ||
| 1 | + // Flags: --expose-internals --max-old-space-size=16 | ||
| 2 | 2 | 'use strict'; | |
| 3 | 3 | ||
| 4 | 4 | // This test ensures that diagnostic channel references aren't leaked. | |
| 5 | 5 | ||
| 6 | - require('../common'); | ||
| 7 | - const { ok } = require('assert'); | ||
| 6 | + const common = require('../common'); | ||
| 8 | 7 | ||
| 9 | - const { subscribe, unsubscribe } = require('diagnostics_channel'); | ||
| 8 | + const { subscribe, unsubscribe, Channel } = require('diagnostics_channel'); | ||
| 9 | + const { checkIfCollectableByCounting } = require('../common/gc'); | ||
| 10 | 10 | ||
| 11 | 11 | function noop() {} | |
| 12 | 12 | ||
| 13 | - const heapUsedBefore = process.memoryUsage().heapUsed; | ||
| 14 | - | ||
| 15 | - for (let i = 0; i < 1000; i++) { | ||
| 16 | - subscribe(String(i), noop); | ||
| 17 | - unsubscribe(String(i), noop); | ||
| 18 | - } | ||
| 19 | - | ||
| 20 | - global.gc(); | ||
| 21 | - | ||
| 22 | - const heapUsedAfter = process.memoryUsage().heapUsed; | ||
| 23 | - | ||
| 24 | - ok(heapUsedBefore >= heapUsedAfter); | ||
| 13 | + const outer = 64; | ||
| 14 | + const inner = 256; | ||
| 15 | + checkIfCollectableByCounting((i) => { | ||
| 16 | + for (let j = 0; j < inner; j++) { | ||
| 17 | + const key = String(i * inner + j); | ||
| 18 | + subscribe(key, noop); | ||
| 19 | + unsubscribe(key, noop); | ||
| 20 | + } | ||
| 21 | + return inner; | ||
| 22 | + }, Channel, outer).then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments