Hi,
Sorry for the bad title but I did not know how to express that well. Let me explain:
I believe that if I assign a same value to different locations in a data structure, the value is only at one memory address but its pointer is copied. For example:
v = 1
m = %{a: v, b: v}
I believe that the value bound to v
and to two map keys occupies a single memory space, but there are multiple pointers to that value. Please correct me if I’m wrong.
If this is true, my question is: What happens when I send my map to another process ? Does the memory structure gets replicated, or is the 1
duplicated in two memory spaces ?
Thank you
(A bit of context, but you can skip that)
I have a large “project” data structure, a map, with some key/values containing generic configs, etc. And one key that contains a list of reports configs. For convenience, I map over the reports configs, copying all the generic config into each report config so, when generating a report, I have my needed data around. I do this copying in the process that must send reports for a particular “project”. But I wonder if I could just copy all that stuff once, for all projects, when I load the configuration initially, and the process that must handle a particular process would receive the reports configs with all generic data into each report config already.
Of course, I am not talking about megabytes here, in practice it does not change much, I do not really care about performance at that point. But it made me wonder.
Also I could use persistent terms here, but again perfs do not matter at the moment.