Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fix reference leak #44499

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions benchmark/process/next-tick-loop-args.js
Original file line number Diff line number Diff line change
@@ -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 changes: 30 additions & 0 deletions benchmark/process/next-tick-loop.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
1 change: 1 addition & 0 deletions lib/internal/fixed_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down