-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
AbortSignal.any() causes memory leak #54614
Labels
abortcontroller
Issues and PRs related to the AbortController API
memory
Issues and PRs related to the memory management or memory footprint.
Comments
This might (I'm not sure) be a duplicate of #48419 |
RedYetiDev
added
abortcontroller
Issues and PRs related to the AbortController API
repro-exists
labels
Aug 28, 2024
$ node repro.js
Mem before loop 44.25 MB
Mem after 1 million iteration 1375.11 MB |
I started taking some snapshot @RedYetiDev would you have any clue? |
RedYetiDev
added
the
memory
Issues and PRs related to the memory management or memory footprint.
label
Sep 25, 2024
I think the issue here is that everything is happening in the same tick. This does not leak for me: const formatMemoryUsage = (data) => `${Math.round((data / 1024 / 1024) * 100) / 100} MB`;
let memoryData = process.memoryUsage();
console.log('Mem before loop', formatMemoryUsage(memoryData.rss));
let i = 0;
function run() {
const abortController = new AbortController();
const signal = abortController.signal;
const composedSignal = AbortSignal.any([signal]);
if (i === 1000000) {
memoryData = process.memoryUsage();
console.log('Mem after 1 million iteration', formatMemoryUsage(memoryData.rss));
} else {
i++;
setImmediate(run);
}
}
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
abortcontroller
Issues and PRs related to the AbortController API
memory
Issues and PRs related to the memory management or memory footprint.
Version
v22.6.0
Platform
Subsystem
https://nodejs.org/api/globals.html#class-abortsignal
What steps will reproduce the bug?
Run this and watch memory usage.
This is what I get on my local machine
How often does it reproduce? Is there a required condition?
Always reproducible as far as I can tell
What is the expected behavior? Why is that the expected behavior?
Memory post loop execution should be fairly equivalent to the first log but somehow the
const composedSignal = AbortSignal.any([signal]);
does not get cleaned up from memory, I would expect this to get cleaned properly or if this is the intended behavior to have a clear warning in the documentation.What do you see instead?
We see a memory leak that will eventually lead to an out of memory error.
Additional information
This has been tested on Node 22.6 on different machine and both Windows + Unix versions. Happy to provide more details if needed
The text was updated successfully, but these errors were encountered: