[erlang-questions] Question about erlang garbage collection

Ulf Wiger ulf@REDACTED
Mon Oct 13 08:06:21 CEST 2014

Well, it *can* degrade system performance if it ends up being called very often.

There are basically two cases where explicitly calling erlang:garbage_collect() might be warranted:

- A process has performed some reasonably expansive operation, and will afterwards to basically nothing for a long time. This might happen in e.g. supervisors.

- After an expansive operation, where memory profiling has shown that it actually improves characteristics to force a garbage collect right there. The most likely benefit, if there is one, is that the old_heap is reduced.

Using explicit GCs should be seen as an optimization, pushing the garbage collector to work more aggressively than it otherwise would. As with all optimizations, you need to measure before and after to ensure that it actually _improves_ things, rather than make things worse.

Ulf W

On 13 Oct 2014, at 03:52, Akash Chowdhury <achowdhury918@REDACTED> wrote:

> Hi,
> I have a question to experienced erlang developers/designers. Have you ever used or felt the need of using erlang:garbage_collect()? Or erlang's default garbage collection is good enough for all situations?
> Erlang man page says that -"This function forces an immediate garbage collection of the currently executing process. The function should not be used, unless it has been noticed -- or there are good reasons to suspect -- that the spontaneous garbage collection will occur too late or not at all. Improper use may seriously degrade system performance."
> Does using this seriously degrade system performance? Any one has experience of using this?
> Thanks.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141013/a4bcbe2b/attachment.htm>

More information about the erlang-questions mailing list