ysmood / yaku

A lightweight promise library
https://tonicdev.com/ysmood/yaku
MIT License
291 stars 28 forks source link

`then` memory leak #37

Closed ysmood closed 4 years ago

ysmood commented 7 years ago

If we call a promise's then method multiple times, it may potentially cause memory leak:

var p = Promise.resolve();

p.then(function () {});
p.then(function () {});
p.then(function () {});
p.then(function () {});
p.then(function () {});

process.on('exit', () => {
    p = null;
});

If we don't release variable p, its children promises will stay in memory even after p and all the children are settled. What we should do with this situation is not specified in the ES6 yet.

I think we should cut off the link between the parent and child immediately after the child is settled.

JakeChampion commented 7 years ago

Have you posted about this on the es-discuss@mozilla.org mailing list?

ysmood commented 7 years ago

No, but I think it's a common issue of Promise libs 2016年11月18日(金) 23:43 Jake Champion notifications@github.com:

Have you posted about this on the es-discuss@mozilla.org mailing list?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ysmood/yaku/issues/37#issuecomment-261563273, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWZQEH1Ix6XrvrXHkvIGpvAcPMB19Q0ks5q_ce0gaJpZM4KPM3R .