<div dir="ltr">I will appreciate If  anyone  can reply to me .</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/14 郎咸武 <span dir="ltr"><<a href="mailto:langxianzhe@gmail.com" target="_blank">langxianzhe@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:14.44444465637207px">Hi All.</span><div><font face="arial, sans-serif"><span style="font-size:14.44444465637207px">In recently, I ran into a problem which the Process consumers a lot of memory. There is roughly from 300M to 450 each process.</span></font><span style="font-family:arial,sans-serif;font-size:14.44444465637207px">。</span></div>

<div><span style="font-family:arial,sans-serif;font-size:14.44444465637207px">The memory will be free if invoke erlang:garbage_collect/</span><span style="font-family:arial,sans-serif;font-size:14.44444465637207px">1。So, In my view , the moemry may is not be used, and do not garbage collect. Why? I can not get it. Please give some for me. </span></div>

<div><span style="font-family:arial,sans-serif;font-size:14.44444465637207px">For further resolve the problem,  I do some test in the </span><font face="arial, sans-serif"><span style="font-size:14.44444465637207px">simplification program. The memery is can garbage collect too(pass an hour).<br>

</span></font><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">Test Method:</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">1、The R variable is about 19489 number records</div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px">(如[{"author_id","users-a9KsYTIRdrq3iuAywiLRE2BGd3Y"},{"timestamp","2013-07-17 10:47:36"},{"time_int",63541277256},{"title",[233,155,133,229,133,184,231,139,172,229,136,155,232,136,170,230,181,183,229,164,169,230,150,135,229,143,176,232,133,149,232,161,168]},{"id","info-137429256786232"}])</div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px">2、Obtain the Process of Pid</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">      (<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)5> Pid = test4:get_pid()</div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px">3、The Pid state before send R data</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)7> erlang:process_info(Pid, memory).</div>

<div><b>{memory,2656}</b></div><div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)8> erlang:process_info(Pid).        </div><div>[{current_function,{test4,loop,0}},</div><div> {initial_call,{test4,loop,0}},</div>

<div> {status,waiting},</div><div> {message_queue_len,0},</div><div> {messages,[]},</div><div> {links,[]},</div><div> {dictionary,[]},</div><div> {trap_exit,false},</div><div> {error_handler,error_handler},</div><div> {priority,normal},</div>

<div> {group_leader,<0.31.0>},</div><div> {total_heap_size,233},</div><div><b> {heap_size,233},</b></div><div> {stack_size,1},</div><div> {reductions,1},</div><div> {garbage_collection,[{min_bin_vheap_size,46368},</div>

<div>                      {min_heap_size,233},</div><div>                      {fullsweep_after,0},</div><div>                      {minor_gcs,0}]},</div><div> {suspending,[]}]</div></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

<br></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">4、 to send  R Data</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)9> Pid ! {self(),R}</div>

<div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)9> .</div><div>{<0.52.0>,</div><div> {ok,[{1,</div><div>       [[{"author_id","users-a9KsYTIRdrq3iuAywiLRE2BGd3Y"},</div>

<div>         {"timestamp","2013-07-17 10......................</div></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">5、The Pid state after  send R data, The memory is increasing.</div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)11> erlang:process_info(Pid, memory).</div><div><b>{memory,51356672}</b></div>

<div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)12> erlang:process_info(Pid).        </div><div>[{current_function,{test4,loop,0}},</div><div> {initial_call,{test4,loop,0}},</div>

<div> {status,waiting},</div><div> {message_queue_len,0},</div><div> {messages,[]},</div><div> {links,[]},</div><div> {dictionary,[]},</div><div> {trap_exit,false},</div><div> {error_handler,error_handler},</div><div> {priority,normal},</div>

<div> {group_leader,<0.31.0>},</div><div><b> {total_heap_size,6419485},</b></div><div><b> {heap_size,6419485},</b></div><div> {stack_size,1},</div><div> {reductions,2002},</div><div> {garbage_collection,[{min_bin_vheap_size,46368},</div>

<div>                      {min_heap_size,233},</div><div>                      {fullsweep_after,0},</div><div>                      {minor_gcs,0}]},</div><div> {suspending,[]}]</div></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

6、to send R data again.</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)13> Pid ! {self(),R}.                </div>

<div>{<0.52.0>,</div><div> {ok,[{1,</div></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">7、The memory  continue to increas.</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)14> erlang:process_info(Pid, memory).</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><b>{memory,125381272}</b></div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px">(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)15> erlang:process_info(Pid).        </div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

[{current_function,{test4,loop,0}},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {initial_call,{test4,loop,0}},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

 {status,waiting},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {message_queue_len,0},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {messages,[]},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

 {links,[]},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {dictionary,[]},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {trap_exit,false},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

 {error_handler,error_handler},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {priority,normal},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {group_leader,<0.31.0>},</div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><b> {total_heap_size,15672560},</b></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><b> {heap_size,15672560},</b></div>
<div style="font-family:arial,sans-serif;font-size:14.44444465637207px">
 {stack_size,1},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {reductions,4003},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {garbage_collection,[{min_bin_vheap_size,46368},</div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px">                      {min_heap_size,233},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">                      {fullsweep_after,0},</div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px">                      {minor_gcs,0}]},</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"> {suspending,[]}]</div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px">

<br></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><b>I am  </b><span style="line-height:19.984375px;font-size:14px;font-family:Helvetica,Arial,'Droid Sans',sans-serif">wondering the cause why  it is can not collect, Please give me some idea. </span><b>Thanks a lot.</b></div>

<div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><b><div>(<a href="mailto:trends1@192.168.16.50" target="_blank">trends1@192.168.16.50</a>)23> erlang:process_info(Pid, memory).</div><div>{memory,195907792}</div>

<div><br></div></b></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><br></div><div style="font-family:arial,sans-serif;font-size:14.44444465637207px"><div><span style="line-height:19.984375px;font-size:14px;font-family:Helvetica,Arial,'Droid Sans',sans-serif">I'm running</span><span style="line-height:19.984375px;font-size:14px;font-family:Helvetica,Arial,'Droid Sans',sans-serif"> </span>Erlang R14B04 on the unbuntu.</div>

<div>Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]和<br></div><div>Linux jason-lxw 3.2.0-55-generic #85-Ubuntu SMP Wed Oct 2 12:29:27 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux<br clear="all">

<div><br></div><div>[1]代码:</div><div><div>  1 -module(test4).</div><div>  2 -export([get_pid/0,</div><div>  3          get_data/1,</div><div>  4          get_pids/1,</div><div>  5          loop/0]).</div><div>  6 </div><div>

  7 get_pids(L) -></div><div>  8     get_pids(0, L).</div><div>  9 </div><div> 10 get_pids(0, L) -></div><div> 11     L;</div><div> 12 get_pids(N, R) -></div><div> 13     NewR = [get_pid()|R],</div><div> 14     get_pids(N-1, NewR).</div>

<div> 15 </div><div> 16 get_pid()-></div><div> 17      spawn_opt(?MODULE, loop, [], [{fullsweep_after,0}]).</div><div> 18      %spawn(?MODULE, loop, []).                                                                                                                   </div>

<div> 19 </div><div> 20 get_data(Pid) -></div><div> 21      Pid ! {self(), get}.</div><div> 22 </div><div> 23 loop() -></div><div> 24     receive</div><div> 25         {From, Data} -></div><div> 26             From ! Data,</div>

<div> 27             loop()</div><div> 28     end.</div></div></div></div><div><br></div><div><br></div><div>Cheers</div><div>Jason </div><span class="HOEnZb"><font color="#888888">-- <br>只为成功找方法,不为失败找理由
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>只为成功找方法,不为失败找理由
</div>