[erlang-questions] process_info(Pid, memory).

Greg Burri greg.burri@REDACTED
Tue Jun 10 10:37:36 CEST 2008


Hi everybody,
I'm coding (just for fun) a little chat system with Erlang based on
Yaws[1]. I'm using some "server push" (also know as COMET) to make a
real time chat.
Basically the client send its state with a XMLHttpRequest() and the
server decide if this state is up to date or not. If not then the
server send the delta and if yes then an event is waiting from Mnesia
and the connection is held.

You can see the actual work here (in french) : http://www.euphorik.ch
Please, don't use MS Internet Explorer, I have some little issues with it.
(you can try to speak in french if you want ;) )


I try to know how much memory each connection have. I'm using
process_info, I have these results :
>process_info(pid(0, 29961, 0), memory).
{memory,142736} (~139kB)

>From where these 139kB come ? I think it's a bit huge.

More details :
> process_info(pid(0, 29961, 0)).
[{current_function,
     {euphorik_protocole,wait_event_bd_page_chat,0}},
 {initial_call,{proc_lib,init_p,5}},
 {status,waiting},
 {message_queue_len,0},
 {messages,[]},
 {links,[<0.65.0>,<0.80.0>,#Port<0.20824>]},
 {dictionary,[..]}
 {trap_exit,false},
 {error_handler,error_handler},
 {priority,normal},
 {group_leader,<0.36.0>},
 {total_heap_size,17711},
 {heap_size,6765},
 {stack_size,58},
 {reductions,3700},
 {garbage_collection,[{fullsweep_after,65535}]},
 {suspending,[]}]

When I suspend (with a simple "receive _ -> ok end") my "COMET"
process before the mnesia event waiting I have variables sizes of
process_info(Pid, memory) from 50kB to 1.5MB depends where I suspend..
It's a bit amazing.
For exemple, if I suspend my process at the begining of
euphorik_protocole:wait_event([{page, "chat"} | Data]) the process
size is around 1.5MB. The source code[2] is available under GPLv3 (the
comments are sadly in french).

So... my questions are :
1. What exactly means process_info(Pid, memory) ?
2. Why my process size varying in a such large difference ?

[1] : http://www.euphorik.ch
[2] : http://svn.euphorik.ch/index.cgi/euphorik/browse/tags/1.0.1/modules/erl
The beginning of the "COMET" process is euphorik_requests:out/1


TIA
/Greg



More information about the erlang-questions mailing list