angular-redux / example-app

Example using @angular-redux/store, @angular-redux/router, and @angular-redux/form together with the Angular CLI
123 stars 101 forks source link

Memory-leaks #34

Closed aminpaks closed 7 years ago

aminpaks commented 7 years ago

I changed two lines in your example and run it. After about 30,000 actions app accumulates up to 300MB memory and crashes.

These are steps to reproduce this issue:

  1. Update addTicket in animal component to, this code simulates dispatching many actions to observe the issue easier:

    addTicket = () => {
    for (let i = 0; i < 10000; i++) {
      setTimeout(() => this.subStore.dispatch({ type: 'ADD_TICKET' }), 1);
    }
    }
  2. Remove the createLogger and devTools enhancer from store/module:

    // Tell Redux about our reducers and epics. If the Redux DevTools
    // chrome extension is available in the browser, tell Redux about
    // it too.
    store.configureStore(
      rootReducer,
      {},
      [ ...rootEpics.createEpics() ]);
  3. Run the app yarn start

  4. Click on + to start the process: this will dispatch 10000 actions and update the UI.

  5. Observe how app crashes after a few times clicking on the plus

You may check the memory in Chrome devTools too.

aminpaks commented 7 years ago

I already fixed the issue in angular-redux/store project, where can I ask for PR? angular-redux/store

SethDavenport commented 7 years ago

Hey - looking into it now. Please understand that I don't get to everything immediately.

SethDavenport commented 7 years ago

I've reproduced the issue and confirmed that your fix works. Thanks, nice catch!

I also took the liberty of creating a PR with from your fork, here: https://github.com/angular-redux/store/pull/409. There are a couple of minor cleanup items after which I'd be happy to merge it.

SethDavenport commented 7 years ago

I cleaned up the PR and merged it. The fix has been released in @angular-redux/store 6.4.1.