Skip to content
This repository has been archived by the owner on Jan 10, 2018. It is now read-only.

Memory leak for dispatcher #167

Closed
flamurey opened this issue Jul 7, 2016 · 13 comments
Closed

Memory leak for dispatcher #167

flamurey opened this issue Jul 7, 2016 · 13 comments

Comments

@flamurey
Copy link

flamurey commented Jul 7, 2016

Hi,

I don't now why but my app have memory leak. By using chrome I detect into heap dump what dispatcher undicrectly contains all actions with payloads. My app frequently load large data and dispatching it.

image

@MikeRyanDev
Copy link
Member

Interesting. Do you think you might be able to reproduce it in a Plunker or in a separate repo?

@flamurey
Copy link
Author

flamurey commented Jul 12, 2016

https://plnkr.co/edit/pzODIm

watching memory profiler you will see as used memory increasing

@asarode
Copy link

asarode commented Sep 17, 2016

Has any progress been made on this?

@dchacke
Copy link

dchacke commented Oct 22, 2016

+1. I have been running into issues with memory as well and am curious if it has to do with this.

@MikeRyanDev
Copy link
Member

I originally left this issue open because we were using a custom built subject for tracking actions. Recent versions of @ngrx/store are just using a BehaviorSubject and the queue scheduler. If this memory problem still persists, this is most likely a bug in rxjs. Thanks!

@michaelcleary
Copy link

I'm using rxjs/store (2.2.1) in an application that puts some fairly large result sets into the store. Unfortunately because of this memory leak the application crashes the browser as the store after a few data requests. If the bug is with rxjs, is it possible something could be done to work around it in ngrx?

@mfahlen
Copy link

mfahlen commented Dec 16, 2016

I'm also seeing memory leaks using @ngrx/store version 2.2.1. It looks like dispatched actions aren't garbage collected. Any help looking into this issue would be greatly appreciated.

@MikeRyanDev
Copy link
Member

@michaelcleary @mfahlen

I have two theories:

  1. Are you using @ngrx/store-devtools? The devtools are going to keep all actions to make recomputing of states possible. There is an option to only retain the last n actions if this is case.
  2. Are you using ngrx-store-logger? If you are using ngrx-store-logger (or something similar to log actions to the console) then the actions won't be able to be garbage collected until the console is cleared.

Let me know if this is not the case and I'll reopen the issue.

@michaelcleary
Copy link

michaelcleary commented Dec 17, 2016 via email

@MikeRyanDev MikeRyanDev reopened this Dec 17, 2016
@MikeRyanDev
Copy link
Member

@Blesh Any ideas? Code path that reproduces this:

const dispatcher = new BehaviorSubject({ type: 'INIT' });

dispatcher.observeOn(queue).subscribe();

Previous actions pushed into the dispatcher subject won't be released anymore.

@josh-sachs
Copy link

I believe I am also being affected by this issue. It is quite severe. Can anyone recommend a previous version of ngrx/store that isn't impacted by this while a resolution is found?

@MikeRyanDev
Copy link
Member

MikeRyanDev commented Jan 2, 2017

For reference, I've opened up an issue about this on the rxjs repo: ReactiveX/rxjs#2244

@kudoz83 There isn't a previous version of @ngrx/store unaffected by this issue. Observing the action stream on a queue prevents action reentrancy.

@MikeRyanDev
Copy link
Member

Fixed in rxjs v5.0.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants