forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: start connections checking interval on listen
Fixes: nodejs#48604.
- Loading branch information
1 parent
32eb492
commit e5c4298
Showing
2 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/parallel/test-http-server-connections-checking-leak.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
// Flags: --expose-gc | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
|
||
// Check that creating a server without listening is not leaking resources. | ||
|
||
const step = 10000; | ||
const max = 100000; | ||
|
||
const usages = []; | ||
|
||
for (let i = 0; i < max; i++) { | ||
if (i % 100 === 0) { | ||
global.gc(); | ||
} | ||
|
||
if (i % step === 0) { | ||
usages.push(process.memoryUsage()); | ||
} | ||
|
||
http.createServer((req, res) => {}); | ||
} | ||
|
||
for (let i = 1; i < usages.length; i++) { | ||
const current = usages[i].heapTotal; | ||
const reference = usages[0].heapTotal; | ||
assert.ok(current / reference < 1.1, `memory usage is increasing (${i}): ${current} > ${reference} * 1.1`); | ||
} |