How does the garbage collector work?

How exactly does the garbage collector work with reduction? We all know that redux contributes to immutability. So what happens to instances of deprecated states? For example, in my gearbox, if I have a case, for example:

...
case 'MY_ACTION':
     return state.set('name', action.name)
... 

Now, if I run the action MY_ACTION100 times, the code will create a new object 100 times.

My question is what will happen to previous state objects that are no longer in use. Will they be left in the javascript / browser garbage collector to decide what to do? If so, isn't that a performance issue, i.e. Too many deprecated state objects increase the load on the javascript garbage collector and thereby reduce code performance?

+4
source share
1 answer

Redx itself is a simple state management library. Everything related to garbage collection is handled by the Javascript engine. Therefore, no, the creators of Redux did not take this into account, because garbage collection has nothing to do with the Redux library itself.

Yes, constant data processing creates more objects than a direct mutation, but JS engines do an excellent job of this.

+3
source

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


All Articles