lib: fix reference leak
PR-URL: https://github.com/nodejs/node/pull/44499 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
parent
f17eac9727
commit
bae03c4e30
37
benchmark/process/next-tick-loop-args.js
Normal file
37
benchmark/process/next-tick-loop-args.js
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
const common = require('../common.js');
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e4, 2e4, 4e4],
|
||||
loop: [1e2, 2e2],
|
||||
});
|
||||
|
||||
function main({ n, loop }) {
|
||||
bench.start();
|
||||
run();
|
||||
function run() {
|
||||
let j = 0;
|
||||
|
||||
function cb() {
|
||||
j++;
|
||||
if (j === n) {
|
||||
loop--;
|
||||
if (loop === 0) {
|
||||
bench.end(n);
|
||||
} else {
|
||||
run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (i % 4 === 0)
|
||||
process.nextTick(cb, i, true, 10, 'test');
|
||||
else if (i % 3 === 0)
|
||||
process.nextTick(cb, i, true, 10);
|
||||
else if (i % 2 === 0)
|
||||
process.nextTick(cb, i, 20);
|
||||
else
|
||||
process.nextTick(cb, i);
|
||||
}
|
||||
}
|
||||
}
|
30
benchmark/process/next-tick-loop.js
Normal file
30
benchmark/process/next-tick-loop.js
Normal file
@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
const common = require('../common.js');
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e4, 2e4, 4e4],
|
||||
loop: [1e2, 2e2],
|
||||
});
|
||||
|
||||
function main({ n, loop }) {
|
||||
bench.start();
|
||||
run();
|
||||
function run() {
|
||||
let j = 0;
|
||||
|
||||
function cb() {
|
||||
j++;
|
||||
if (j === n) {
|
||||
loop--;
|
||||
if (loop === 0) {
|
||||
bench.end(n);
|
||||
} else {
|
||||
run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
process.nextTick(cb);
|
||||
}
|
||||
}
|
||||
}
|
@ -111,6 +111,7 @@ module.exports = class FixedQueue {
|
||||
if (tail.isEmpty() && tail.next !== null) {
|
||||
// If there is another queue, it forms the new tail.
|
||||
this.tail = tail.next;
|
||||
tail.next = null;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user