1// Flags: --expose-gc 2'use strict'; 3 4// This test ensures that diagnostic channel references aren't leaked. 5 6require('../common'); 7const { ok } = require('assert'); 8 9const { subscribe, unsubscribe } = require('diagnostics_channel'); 10 11function noop() {} 12 13const heapUsedBefore = process.memoryUsage().heapUsed; 14 15for (let i = 0; i < 1000; i++) { 16 subscribe(String(i), noop); 17 unsubscribe(String(i), noop); 18} 19 20global.gc(); 21 22const heapUsedAfter = process.memoryUsage().heapUsed; 23 24ok(heapUsedBefore >= heapUsedAfter); 25