How Elixir Manages Memory?

Elixir uses persistent data structures. These data structures are meant to, first and foremost, preserve previous versions of themselves. The nice thing here is that you aren’t taking more traditional data structures and trying to glue persistence on top of them. If lists were build using arrays, or maps built using dictionaries, the cost of modification would be high (O(N) in time and memory).

Lists are built using linked lists and maps, once they grow past a certain point, are HAMTs. Both of these are able to be modified efficiently. Lists are still quite sensitive to the specific operation (a prepend is O(1) while an append is O(n)) though.