-
Notifications
You must be signed in to change notification settings - Fork 12
Should it be destoyed when Promise.resolve is invoked? #16
Comments
Promises are destroyed by gc, so the data of promise will be removed later, which is similar to the situation you mention. I raise a example below, if your problem hasn't been solved, please show me you code. node --expose-gc test.js const als = require('async-local-storage');
als.enable();
setTimeout(() => {
new Promise((resolve) => {
als.set("a", 1);
resolve();
}).then(() => {
als.set("b", 1);
// getAllData is supported in version 2.2.0
console.dir(als.getAllData());
return Promise.resolve();
})
})
setTimeout(() => {
console.dir(als.getAllData());
global.gc();
}, 1000)
setTimeout(() => {
console.dir(als.getAllData());
}, 2000); |
@cmershen1 Has the problem you mentioned been solved? |
my question has not been solved yet.
|
I tried to print the map, the output is like this: and the layer becomes more and more deeper. |
It seem abnormal and I found that each item of data you shown 2ms deviated. Did you use Can you please show me complete and operational codes, otherwise I can't help you. |
my server runs on the rpc framework maybe we can find some clues in : |
You can use scope function to create a new scope. |
how to use I use app.js:
FooBarImp.js:
|
Yes, you can use |
@vicanso then go to '~/src/render/server/server.js' and check my code. if you run 'als.map()' see in each time map It gets bigger. |
Try to call gc like this commemt. |
if i use GC in high traffic ,am I not mistaken by run gc and cleanup memory between other Express request. i have another problem. in first run (node v12.10.0, npm 6.11.3) have this error:
|
it has error |
i back to pass down way and remove async-local-storage because have more memory leak. |
The map gets bigger may be not memory leak. Some data will be removed after gc, so you should check the map after gc. If you want to use node --expose-gc app.js |
when the
resolve
function is invoked, thepromiseResolve
callback function will be called.I used your library in my project, and got memory leak in the end.
I think the reason is
promiseResolve
isn't handled. Am I right?The text was updated successfully, but these errors were encountered: