Will an application based on immutable data structures run out of memory?

Ignore the reduction or something like that - I'm just asking about Immutable.JS, Ramda, etc.

If new versions of the data structure are created by sharing structures, this means that each new version must have a pointer to the previous version in order to be able to share something. This again means that old versions of the structure cannot be garbage collected, which means that in an application where you have a state, this state will use a monotonously increasing amount of memory. If so, then this data structure at some point used all available memory if it continued to change.

Am I missing something? I see that for many (most) cases of use on the Internet (in the browser) this will not be a problem, since you probably just change a tiny part of the structure every time, and you probably leave the page or reload it before using all memory, but for lengthy processes this should create a problem. Correctly? Riiiight?

+4
source share
1 answer

If new versions of the data structure are created by sharing structures, this means that each new version must have a pointer to the previous version in order to be able to share something.

. . , ( ) .

, Ocaml ( - ) : . Map. ( ) () , , ( ) .

, "" , "".

- BTW ( -) . . Byrd - C.Queinnec.

.

+5

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


All Articles