addressing a lot of processes

Matthias Lang <>
Fri May 20 19:44:28 CEST 2005


 > On 20 May 2005, at 16:23, Gaspar Chilingarov wrote:

 > > For now, I've implemented sample manager, which maps IP(string) to PID
 > > using gb_trees. In another hand, I've seen sample in some erlang
 > > sources, to register process under unique name say ip_127.0.0.1,
 > > ip_127.0.0.2 etc.
 > >
 > > This leads to generating the new atoms in runtime, and I'm conscious 
 > > that erlang's GC will not clean them if they are unused. Am I right?

IP(string) and IP(atom) aren't the only representations. In this case,
IP(tuple) would also make sense, and the conversion is easy:

  {ok, Tuple} = inet:getaddr(String, inet)

IP(integer) is another possibility, i.e.

  {ok, {A,B,C,D}} = inet:getaddr(String, inet),
  Integer = (A bsl 24) + (B bsl 16) + (C bsl 8) + D.

Then you don't have to worry about the atom table _and_ you have a
useful representation.

Matthias



More information about the erlang-questions mailing list