Executing in constance space + memory usage

Ulf Wiger (AL/EAB) <>
Wed Apr 20 17:38:24 CEST 2005


On 20 April 2005 17:08, Joel Reymont wrote:

> Is there a way to find out the memory used by a process? 
> 
> I found references to the various code profilers but the
> only thing I know that reports memory usage is
> erlang:memory() and that is for the emulator overall. 

You should look at Pan:
http://cvs.sourceforge.net/viewcvs.py/jungerl/jungerl/lib/pan/#dirlist

I believe it is capable of doing pretty much what 
I'm attempting to describe below.

/Uffe

You can try tracing on garbage collections. This will
give you a good idea of how often GCs occur, how
big they are, and were before the GC. If you combine
GC trace with function call trace, you can find out
which function triggered the GC. This can be a good
way to single out functions that could be optimized.
Note that it's by no means certain that the function
which triggers the GC is doing something it shouldn't.

However, if you save the trace output, you can correlate
function call trace and GC trace messages, sort them on
the difference between the new heap size and the old.
This can give pretty good indications.

If you use dbg and report trace data to the tty,
just be careful not to include the dbg server or 
the user process in the trace, as this may cause 
a storm of trace messages.

Example:

8> dbg:tracer().
{ok,<0.48.0>}
9> dbg:p(new,[c,arity,garbage_collection]).
{ok,[{,0}]}
10> dbg:tpl('_','_','_',[]).
...
(<0.53.0>) call erl_parse:yeccpars2/7
(<0.53.0>) call erl_parse:yeccpars1/5
(<0.53.0>) call erl_parse:yeccpars2/7
(<0.53.0>) call erl_parse:yeccpars1/5
(<0.53.0>) call erl_parse:yeccpars2/7
(<0.53.0>) gc_start [{old_heap_block_size,0},
 {heap_block_size,233},
 {mbuf_size,0},
 {recent_size,0},
 {stack_size,7},
 {old_heap_size,0},
 {heap_size,221}]
(<0.53.0>) gc_end [{old_heap_block_size,0},
 {heap_block_size,233},
 {mbuf_size,0},
 {recent_size,111},
 {stack_size,7},
 {old_heap_size,0},
 {heap_size,111}]



More information about the erlang-questions mailing list