[erlang-questions] module syntax help

Richard Carlsson richardc@REDACTED
Tue Apr 14 09:20:57 CEST 2009

Steve Davis wrote:
> If you call new twice, e.g.
> 1> P = mymodule:new(Params).
> 2> P = mymodule:new(Params).
> I'd be right in thinking that P is exactly the same instance of the
> parameterized module, correct?
> i.e. if I call mymodule:new(Params) with the same parameters 100000
> times there's no memory (or otherwise) impact on the VM?

The impact would be similar to running the following function
the same number of times:

   new(P1,...,Pn) ->  {some_tag, P1, ..., Pn}..

I.e., a small object is created on the heap, on the order of n+k
words for some small k. As usual, these will be garbage collected
when they are no longer referenced. (The current representation
uses tuples, but this is meant to change, so never rely on that.)


More information about the erlang-questions mailing list