emberjs / data

A lightweight reactive data library for web applications. Designed over composable primitives.
https://api.emberjs.com/ember-data/release
Other
3.03k stars 1.33k forks source link

Ember Data Memory Leak for multiple requests #6910

Closed dknz2008 closed 4 years ago

dknz2008 commented 4 years ago

To replicate the bug, clone and run in browser. https://github.com/dknz2008/ember-data-autorefresh-bug

Description

This is a minimal example which displays some results from a mocked API to illustrate a memory leak. Every 2 seconds the model is refreshed which calls this.store.unloadAll() and this.store.findAll(). However, every API request causes about 100kb of data to be allocated in memory that is never garbage collected. This matches up with the size of the data from the API, increasing the number of fields results in more memory being consumed on every refresh request. This should not be happening as this.store.unloadAll() should free all records in the store.

Selection_006

routes/application.js is as follows:


  refreshInterval: 2 * 1000,
  model() {
    this.store.unloadAll();
    return this.store.findAll('boardgame')
  },
  autoRefreshTimer: task(function *() {
    while (true) {
      yield timeout(this.refreshInterval);
      this.refresh();
    }
  }).on('init'),
});

### Versions

└─ ember-source@3.7.3
Done in 0.43s.
yarn list v1.21.1
└─ ember-cli@3.7.1
Done in 0.44s.
yarn list v1.21.1
└─ ember-data@3.7.0
dknz2008 commented 4 years ago

currently rechecking as may have made mistake