const Rx = require('rxjs/Rx');
Rx.Observable.interval(500)
.groupBy(
i => i,
null,
i => i.take(1)
)
.subscribe(
null,
err => console.log('err: ' + err),
() => console.log('completed')
);
Invoke code using node --debug-brk --inspect index.js
attach the chrome debugger
take heap snapshot before letting code run
after ~30 seconds take another heap snapshot
=> 60 GroupDurationSubscriber's still around in memory
Expected behaviour:
GroupDurationSubscribers should be removed from the (GroupBy) parent subscription once completed.
Actual behaviour:
GroupDurationSubscribers are retained in memory.
Additional information:
When the GroupDurationSubscriber is completed it invokes this.parent.removeGroup which removes the group but it never invokes this.parent.remove(this) to let the parent (groupBy operator) remove the reference to the GroupDurationSubscriber so it can be garbage collected.
RxJS version: 5.4.0
Code to reproduce:
node --debug-brk --inspect index.js
Expected behaviour:
GroupDurationSubscribers should be removed from the (
GroupBy
) parent subscription once completed.Actual behaviour:
GroupDurationSubscribers
are retained in memory.Additional information:
When the
GroupDurationSubscriber
is completed it invokesthis.parent.removeGroup
which removes the group but it never invokesthis.parent.remove(this)
to let the parent (groupBy
operator) remove the reference to theGroupDurationSubscriber
so it can be garbage collected.This behaviour was implemented in rxjs4
Only when the
GroupBy
operator completes are all the subscriptions let go off and garbage collected.