[erlang-questions] how to seek Leaking processes ?

Morgan Segalis msegalis@REDACTED
Wed Jun 20 20:53:00 CEST 2012


To Everyone !

Thank you all for your help… I have been able to find the leak thanks to all of you…

Here's what I ended up with : 

info() ->                                                              
    [{init, InitProcesses}] = ets:lookup(table_process, init),         
    CurrentProcesses = erlang:processes(),                             
    DiffProcesses = lists:subtract(CurrentProcesses, InitProcesses),   
    get_info(DiffProcesses, dict:new()).                               
                                                                       
get_info([], Dict) ->                                                  
    io:fwrite("Dict: ~p~n", [Dict]);                                   
get_info([P|L], Dict) ->                                               
    case erlang:process_info(P, dictionary) of                         
        {dictionary, Info} ->                                          
            Initial_call = get_dict('$initial_call', Info),            
            Ancestor = get_dict('$ancestors', Info),                   
            case dict:find({Initial_call, Ancestor}, Dict) of          
                {ok, Nb} ->                                            
                    IncrNb = Nb + 1;                                   
                error ->                                               
                    IncrNb = 1                                         
            end,                                                       
            Dict2 = dict:store({Initial_call, Ancestor}, IncrNb, Dict),
            get_info(L, Dict2);                                        
        undefined ->                                                   
            case dict:find(undefined, Dict) of                         
                {ok, Nb} ->                                            
                    IncrNb = Nb + 1;                                   
                error ->                                               
                    IncrNb = 1                                         
            end,                                                       
            Dict2 = dict:store(undefined, IncrNb, Dict),               
            get_info(L, Dict2)                                         
    end.                                                               

With at the end of the start : 

ets:new(table_process, [named_table, protected, set, {keypos, 1}]),
ets:insert(table_process, {init, erlang:processes()}).

The ets table give me the ability to remove all Erlang's VM processes of the dictionary !

Hope it helps someone else,

Morgan.

Le 20 juin 2012 à 13:45, Morgan Segalis a écrit :

> Hi everyone !
> 
> My Erlang App seems to have a process leak…
> I would like to know if there is a technic in order to seek any process leak in Erlang ? (pinpoint the module that leaks, or get the module of the leaked process)
> 
> I cannot seems to be able to reproduce the issue manually, I only see it on production servers.
> 
> Any help, or hint would be greatly appreciated.
> 
> Thank you,
> 
> Morgan.




More information about the erlang-questions mailing list