Allan Streib
unread,Jul 10, 2012, 12:10:45 PM7/10/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to erlan...@googlegroups.com
Hi all,
I attended the Erlang camp in Chicago a couple of years ago. I am
finally getting a chance to use some OTP "for real" so I'd consider
myself to be still pretty much at the beginner level. I am running into
a situation where one of my processes seems to be consuming memory.
Eventually I will get a crashdump with a message like:
eheap_alloc: Cannot allocate 50152200 bytes of memory (of type "heap")
Thought I'd throw this out to see if anyone can give me some pointers of
where to hunt for this. Some details of what I've found below.
The application, called stats_collect, has some processes which are
subscribers to AMQP (RabbitMQ) message queues, and forward some message
statistics to a named process (sc_db_serv) which passes them off to
worker processes (simple one-for-one) for storage into a database. This
sc_db_serv process is where the bulk of the memory growth is happening.
Some details...
Shortly after starting the application, memory() returns:
[{total,4967512},
{processes,1096856},
{processes_used,1089936},
{system,3870656},
{atom,354829},
{atom_used,352561},
{binary,107752},
{code,2538745},
{ets,163116}]
... and later:
[{total,51882592},
{processes,41724296},
{processes_used,41717376},
{system,10158296},
{atom,354829},
{atom_used,352594},
{binary,6388912},
{code,2544953},
{ets,163548}]
Running the i() command I found that sc_db_serv showed by far the most
heap growth. This is also supported by my inspection of the crash dump,
which showed the sc_db_serv process in a "Garbing" state.
Pid Initial Call Heap Reds Msgs
Registered Current Function Stack
<0.48.0> sc_db_serv:init/1 4181 29950 0
sc_db_serv gen_server:loop/6 9
(later)...
<0.48.0> sc_db_serv:init/1 10030440 3156134 0
sc_db_serv gen_server:loop/6 9
I'm not seeing anything accumulating in the message queue for sc_db_serv:
56> sys:get_status(sc_db_serv).
{status,<0.48.0>,
{module,gen_server},
[[{'$ancestors',[<0.47.0>,stats_collect_sup,<0.45.0>]},
{'$initial_call',{sc_db_serv,init,1}}],
running,<0.47.0>,[],
[{header,"Status for generic server sc_db_serv"},
{data,[{"Status",running},
{"Parent",<0.47.0>},
{"Logged events",[]}]},
{data,[{"State",
{state,3,<0.47.0>,<0.57.0>,[],
{[],[]},
[<0.49.0>,<0.53.0>,<0.55.0>]}}]}]]}
57> erlang:process_info(list_to_pid("<0.48.0>")).
[{registered_name,sc_db_serv},
{current_function,{gen_server,loop,6}},
{initial_call,{proc_lib,init_p,5}},
{status,waiting},
{message_queue_len,0},
{messages,[]},
{links,[<0.49.0>,<0.53.0>,<0.55.0>,<0.47.0>]},
{dictionary,[{'$ancestors',[<0.47.0>,stats_collect_sup,
<0.45.0>]},
{'$initial_call',{sc_db_serv,init,1}}]},
{trap_exit,true},
{error_handler,error_handler},
{priority,normal},
{group_leader,<0.44.0>},
{total_heap_size,10030440},
{heap_size,10030440},
{stack_size,9},
{reductions,3159648},
{garbage_collection,[{min_bin_vheap_size,46368},
{min_heap_size,233},
{fullsweep_after,65535},
{minor_gcs,0}]},
{suspending,[]}]
Wondering what else I can do to find out what is causing this heap
growth. Thanks for any suggestions.
Allan
--
Allan Streib