-
Notifications
You must be signed in to change notification settings - Fork 202
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
[Select pattern] prevent memory leak #427
Comments
Are you talking about the selection pooling used by |
here is an example that illustrate what I am talking about: export class Counter {
private sub;
constructor(private ngRedux: NgRedux<IAppState>) {
this.sub = this.ngRedux.select('counter').subscribe(v => console.log(v));
}
ngOnDestroy() {
this.sub.unsubscribe();
}
} Every time I subscribe, two new instance of |
In our app we see same kind of memory leak (and because of this, all Angular components which use @select are not released - huge memory leak). If we downgrade to 6.2.1 the leak disappears. 6.4.3 is the first version where the leak seems to exist. Our usage pattern is simple - usually we make the subscribe and sometimes use async pipe - in my initial tests both approaches leak. Our app is quite large, and the leak might well be some other side-effect of something totally different. Versions: angular-cli (1.1.3) and angular 4.2.4. Example of our usage pattern: ngOnDestroy() { |
In out app we've also noticed quite a leak related to rxjs/async pipe and were able to track it down to this problem: ReactiveX/rxjs#2675. Maybe it's the same one as yours. |
@aitboudad: I've reproduced your issue here: SethDavenport/example-app@7b5696d This is with 6.5.3 Looking into it. |
@ilkkaparssinen I suspect what you're seeing may be different - can you update to 6.5.3 and let me know it if still happens? |
I've traced @aitboudad's issue down to the use of If I do a straight up Looking into what we can do to solve both issues simultaneously. CC: @e-schultz |
OK ... wound back to before the fix for #372 and the leak isn't present. So The investigation continues. |
When creating an observable of the store, make sure the new observable closes down the resources it's using. This particular leak was introduced in 6.3.0.
@aitboudad I believe I have a fix for your leak. Can you try out 6.5.4-alpha.0 and let me know? @ilkkaparssinen still looking into yours. |
@ilkkaparssinen I can reproduce components with The good news is that this is also fixed in 6.5.4-alpha.0. It must have been a symptom of the same issue. I'll push out 6.5.4 shortly with the fix. |
6.5.4 released. |
6.5.4 Fixes the issue for us. Thanks for everybody & sorry for the late response (I'm currently on vacation...). |
great, glad to hear it |
@SethDavenport you can try to make use of drool to do automated leak tests on your example app. Which allow you to prevent leaks in release v. @kgarlikowski @ilkkaparssinen @aitboudad This is also apply for your product since you can avoid to upgrade a lib if it introduce leaks. |
Yeah it would be good to automate leak checking. Ideally as a prepublish step in angular-redux/store itself, e.g. after linting and unit tests. |
drool seems to use selenium though; angular-redux/store's test chain just runs in nodejs since there's no direct dependency on the DOM. I'd prefer to keep it that way since it's a lot simpler to maintain the tooling that way. I was toying with the idea of using nodejs heap dump tools to bake my own simple check but haven't gotten to it yet. |
This is a...
What toolchain are you using for transpilation/bundling?
Actual Behaviour:
When using select pattern I noticed that all created instances doesn't released after unsubscribing which can raise memory leak
The text was updated successfully, but these errors were encountered: