[erlang-questions] how to debug memory leaks?
Ulf Wiger
ulf.wiger@REDACTED
Sat Dec 4 15:28:44 CET 2010
On 4 Dec 2010, at 15:10, Alain O'Dea wrote:
> It is normal for the heap to increase over time. AFAIK, Erlang GC
> occurs rarely unless a process dies or memory is low. This is similar
> to how Java's GC works. It is not unusual for a JVM to gradually
> consume more memory as it runs without indicating a memory leak.
Actually, GCs happen very frequently in Erlang, as soon as a process
heap fills up. The heap size is increased if removing the garbage is
not sufficient to allocate the next term on the heap.
Among the things suggested so far, I'd also look at the process
dictionary. It will be part of the output from sys:get_status/1 or
process_info/1, but e.g.
erts_debug:flat_size(process_info(Pid, dictionary))
could be a way to monitor it.
Another useful technique is to use
erlang:system_monitor(MonitorPid, [{large_heap, Limit}])
and having the MonitorPid call process_info/1 on the process in
question, any time it receives a large_heap message.
BR,
Ulf W
Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com
More information about the erlang-questions
mailing list