1'use strict'; 2 3// Flags: --expose-gc 4 5// Check that creating a server without listening does not leak resources. 6 7require('../common'); 8const onGC = require('../common/ongc'); 9const Countdown = require('../common/countdown'); 10 11const http = require('http'); 12const max = 100; 13 14// Note that Countdown internally calls common.mustCall, that's why it's not done here. 15const countdown = new Countdown(max, () => {}); 16 17for (let i = 0; i < max; i++) { 18 const server = http.createServer((req, res) => {}); 19 onGC(server, { ongc: countdown.dec.bind(countdown) }); 20} 21 22setImmediate(() => { 23 global.gc(); 24}); 25