-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cache): get correct caching behavior #1765
Conversation
This is an initial pass at fixing the cache operator. There is still a lot to do. Ideally, the cache operator would use the lift mechanism. Also this is not well optimized as it is introducing a lot of closures. But it works, and that's the point for now. fixes #1628
(finally) lol |
Merged after quick review from @kwonoj |
Kind of sad that it's all "rx4", but you know that already. |
@staltz, yeah, I'll iterate on it. |
@Blesh Is the difference between this and To phrase it another way, it seems like this operator now permanently leaks memory until the source emits an error. If true, this troubles me greatly. |
Where is the leak? Can it be demonstrated? |
// push 1000000 numbers into cache's ReplaySubject
const source = Observable.range(0, 1000000).cache();
const subscription = source.take(100000).subscribe({
complete() {
console.log(`cache's ReplaySubject now has 100000 values`);
}
});
// cache now has a reference to a ReplaySubject with 100000 values.
// in order to release the reference for GC, I have to set source to null,
// but I can't since it's is a const.
subscription.unsubscribe(); // <-- this should do it |
Is there documentation anywhere about how |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This is an initial pass at fixing the cache operator. There is still a lot to do, but this is merge-worthy IMO. Ideally, the cache operator would use the lift mechanism. Also this is not well optimized as it is introducing a lot of closures. But it works, and that's the point for now.
fixes #1628