-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Clear kResourceStore in timers and intervals #53408
Comments
cc @nodejs/diagnostics @anonrig |
|
I guess this is not only relevant for timers and intervals, all resources are effected. const { AsyncLocalStorage, AsyncResource } = require('node:async_hooks');
const als = new AsyncLocalStorage();
let r, p;
als.run("I consume a lot memory", () => {
r = new AsyncResource("aResource", { requireManualDestroy: true })
r.emitDestroy()
p = Promise.resolve()
})
console.log(r, p); AsyncResource {
[Symbol(async_id_symbol)]: 2,
[Symbol(trigger_async_id_symbol)]: 1,
[Symbol(kResourceStore)]: 'I consume a lot memory'
} Promise {
undefined,
[Symbol(async_id_symbol)]: 3,
[Symbol(trigger_async_id_symbol)]: 1,
[Symbol(kResourceStore)]: 'I consume a lot memory'
} For timers/intervals it's likely easier to find the place to cleanup. |
Absolutely! |
As noted in this article, the timeout/interval objects keep a reference to the store even after they have been cleared.
I think it would be better to clear up that reference inside the
clearTimeout()
andclearInterval()
functions. We might also want to consider exposing an API for end-users and explicit lifetime tracking.The text was updated successfully, but these errors were encountered: