[erlang-questions] how to debug memory leaks?
Sun Dec 5 00:21:24 CET 2010
2010/12/4 Ulf Wiger <>
> On 4 Dec 2010, at 16:40, Attila Rajmund Nohl wrote:
> > Ah, I have a GREAT story about this. We've received TRs that our
> > program was crashing. It turned out that the Linux OOM-killer was
> > killing some of our processes, because the OS ran out of memory. We
> > saw that the process heap of some processes were quite big (tens of
> > MBs), but calling erlang:garbage_collect(Pid) on them decreased it to
> > the KB range - which was really strange.
> <good story snipped/>
> The reason why processes can remain large without getting GCed, is
> that they have probably just increased their heap size dramatically in
> order to store a very big term - heap size being increased in fibonacci
> steps, so possibly allocating more space than stricly necessary - and
> after that, not done enough processing to fill the heap with garbage,
> triggering another GC.
Also, another problem that might cause memory not being deallocated is idle
processes. Idle processes will not get gc'ed since they do not grow heap. So
one can have processes with quite large heaps, for reasons just mentioned by
Ulf for instance, that never get gc'ed.
Related to this is that processes are not checked for gc when they are
scheduled out, a gc check is done at the moment the process gets scheduled
in. This is for performance reasons but the flip side of this is the risk of
increased memory consumption.
> Ulf W
> Ulf Wiger, CTO, Erlang Solutions, Ltd.
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
More information about the erlang-questions