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