[erlang-questions] Erlang proccess memory usage
Chris Hicks
silent_vendetta@REDACTED
Tue May 10 06:29:12 CEST 2011
The first problem you are running into is that you are mistaking "words" for "bytes" see: http://www.erlang.org/doc/efficiency_guide/advanced.html
With that information in mind this is what you are really looking at for 1M processes:
From: wsong.cn@REDACTED
Date: Tue, 10 May 2011 11:55:04 +0800
To: erlang-questions@REDACTED
Subject: Re: [erlang-questions] Erlang proccess memory usage
Also I tried to use proc_lib:hibernate/3 with no difference.
On Tue, May 10, 2011 at 11:50 AM, Wenqiang Song <wsong.cn@REDACTED> wrote:
Hi,
I'm experimenting with Erlang process and found something that not expected.
What I do is creating 1M Erlang processes and measure memory usage. Code is as follow:
-module(generator).-export([start/0, generator/2, loop/0]).
start() -> Pid = self(), spawn( fun()->generator(19,Pid) end ), count (1).
count (Num) -> receive add ->% io:format("Oopss, ~n"),
if 0 =:= ( Num rem 10000 ) -> io:format("Count ~p~n", [Num]);
true -> Q = 3 end, count (Num + 1);
_ -> io:format("haha, ~n") after 30000 ->
io:format("Count ~p~n", [Num]), count (Num) end.
loop() -> receive _ -> io:format("Oops ~n"),
% proc_lib:hibernate(?MODULE, loop(), []) loop() end.
generator( 0, Pid ) -> Pid ! add,% proc_lib:hibernate(?MODULE, loop(), []); loop();generator( Depth, Pid ) -> spawn( fun()->generator(Depth - 1, Pid) end),
spawn( fun()->generator(Depth - 1, Pid) end), Pid ! add,% io:format("Depth: ~p, pid: ~p~n", [Depth, Pid]),% proc_lib:hibernate(?MODULE, loop(), []).
loop().===============End of Code=============2> i(0,58,0).[{current_function,{generator,loop,0}}, {initial_call,{erlang,apply,2}}, {status,waiting},
{message_queue_len,0}, {messages,[]}, {links,[]}, {dictionary,[]}, {trap_exit,false}, {error_handler,error_handler}, {priority,normal}, {group_leader,<0.25.0>},
{total_heap_size,233}, {heap_size,233}, {stack_size,1}, {reductions,9}, {garbage_collection,[{min_bin_vheap_size,46368}, {min_heap_size,233},
{fullsweep_after,65535}, {minor_gcs,0}]}, {suspending,[]}]
3> memory().[{total,2759895784},
{processes,2751081712}, {processes_used,2751067504}, {system,8814072}, {atom,615121}, {atom_used,589205}, {binary,8608}, {code,5845747}, {ets,270928}]
Total memory usage is about 2.7G. While when I use i() and i(pid) I saw that each process only uses about 233 bytes. I can't find where the memory is used. Any idea?
ThanksAndy
--
有志者,事竟成,破釜沉舟,百二秦关终属楚
苦心人,天不负,卧薪尝胆,三千越甲可吞吴
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110509/6702eb4a/attachment.htm>
More information about the erlang-questions
mailing list