I've been running into very strange memory behaviour with merged async iterables.
Some investigation leads me to believe Promise.race is the culprit.
I used this test-case locally:
// every 10 minutes
const slowMovingIterable = interval(600000);
const fastMovingIterable = interval(10).pipe(
// we map it to something big
map(() => Array.from({ length: 3000 }).map(() => Math.random())),
);
merge(slowMovingIterable, fastMovingIterable).forEach(() => {});
Then I looked at the memory tools in chrome and found that memory was steadily increasing. It seems that promise references are kept around in memory until both promises have emitted when using Promise.race
If I change the interval of the slow moving observable to 10 then memory usage is stable.
I've been running into very strange memory behaviour with
merge
d async iterables.Some investigation leads me to believe
Promise.race
is the culprit.I used this test-case locally:
Then I looked at the memory tools in chrome and found that memory was steadily increasing. It seems that promise references are kept around in memory until both promises have emitted when using
Promise.race
If I change the interval of the slow moving observable to
10
then memory usage is stable.