From 72424dd46fb33601848bdac17df96e3855f98def Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 22 Oct 2023 11:25:57 +0200 Subject: [PATCH] test: remove test-diagnostics-channel-memory-leak.js There is no reliable way to detect this leak because: 1. We cannot reliably get a reference to the channel from the API to detect finalization without creating another strong reference. 2. This test does gc() and then checks memory usage - however the use of gc() disables code aging which can actually lead to increased memory usage overall, as it is not intended to be used to lower memory usage in the first place. 3. The implementation of diagnostics channels relies on ephemeron gc which is inefficient, it's not reliable to use the typical "create a lot of objects and see if it crashes" trick to check leaks. To avoid flakiness in the CI, it's better to remove an unreliable test altogether. --- .../test-diagnostics-channel-memory-leak.js | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 test/parallel/test-diagnostics-channel-memory-leak.js diff --git a/test/parallel/test-diagnostics-channel-memory-leak.js b/test/parallel/test-diagnostics-channel-memory-leak.js deleted file mode 100644 index 9e6364d168562f..00000000000000 --- a/test/parallel/test-diagnostics-channel-memory-leak.js +++ /dev/null @@ -1,24 +0,0 @@ -// 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);