Bug 150295
| Summary: | [ES6] Typical Promise chain easily exhaust memory | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Yusuke Suzuki <ysuzuki> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | sam |
| Priority: | P2 | ||
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Yusuke Suzuki
This is originally reported in Chromium/Blink context[1].
In the following example,
```js
"use strict";
var p = null;
(function () {
var N = 1000 * 1000;
var counter = 0;
var resolve;
function read() {
return Promise.resolve({done: ++counter >= N});
}
function pump() {
return read().then(function(r) {
if (counter % 10000 == 0)
gc();
if (r.done) {
return;
}
return pump();
});
}
p = pump();
}());
```
Since it chains promises like `a => b => c => ... too much promises => final`, if there are too much promises, it exhausts memory.
This behavior is well-specified correct behavior, but in practice, we would like to collect / reduce these promises.
[1]: https://github.com/domenic/streams-demo/issues/4
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |