[erlang-questions] [Q] Copying memory between processes

Ladislav Lenart lenartlad@REDACTED
Wed May 23 11:23:48 CEST 2007


Hello,

I encountered a very odd problem that I think is related
to how a term is copied from sender's heap to the heap of
the receiver...

I have a "complex" data structure
Structure = [{Key, Item}]
Item      = term that among other things references all
             items that are in Structure before it.

During the construction of this structure (in one process)
memory allocated by the whole Erlang runtime is about 15MB,
because all the items are shared.

But as soon as this structure is sent to one other process
the system is suddenly out of resources. The only reason
this could happen (that I could think of) is: When the
structure is copied to the heap of the other process, the
identity is not preserved, that is each item references its
own list of previous items (though equal). This would explain
expontential growth of the memory.

Am I right? And if it so, what is the reason (performance)?

Thanks,

Ladislav Lenart





More information about the erlang-questions mailing list