Can a Redux Store Lead a Memory Leak?

I have a dashboard application updating multiple charts at a given interval. My first thought was to update the data in the store, and then let all the charts feed from there.

But can this lead to a memory leak? Because Redux creates a new store every time the data changes and the old ones are saved. Will data ~ 2 MB in size be accumulated every second and application failure?

An alternative that I see is storing data in a local state (using setState). I hope some more experienced React / Redux developers can advise me on this. Thank!

+4
source share
4 answers

Dan Abramov, the creator of Redux, solves this problem here as follows:

, Redux , . . , , . , , , , . , Redux , , webapps, .

, .

+4

" Redux , ".

Vanilla Redux , Redux . , , , .

, -

window.states = []
store.subscribe(() => {
  window.states.push(store.getState())
})

.

, Redux , , , .

+3

-, . , ?

-, Redux . , , . Redux , Redux DevTools , .

Redux. , . http://redux.js.org/docs/faq/Performance.html, http://redux.js.org/docs/recipes/StructuringReducers.html.

Redux, , , .

+3

It is not recommended to accumulate 2 MB of data / second in the user's browser. In the browser, the Redux server is the client side. As far as I know, another part of the memory leak issue does not occur. Some useful links:

Diagnose memory leaks with Chrome devtools

Four types of memory leaks to keep track of

+1
source

Source: https://habr.com/ru/post/1657195/


All Articles