[erlang-questions] Turn off Garbage Collection for a time

Mikael Pettersson mikpelinux@REDACTED
Wed Jun 1 19:11:06 CEST 2016


Tobias Pfeiffer writes:
 > Hi everyone,
 > 
 > is there a way in Elixir/Erlang to turn off the Garbage collection? I've
 > searched and what I found so far is :erlang.garbage_collect to force
 > garbage collection.http://erlang.org/doc/man/erlang.html#garbage_collect-0
 > 
 > I was also made aware of :erlang.spawn_opt/2 http://erlang.org/doc/man/erlang.html#spawn_opt-2 and setting a high value for min_heap_size + setting fullsweep_after.
 > 
 > Is there any way to turn it off completely?

No.

A VM using copying garbage collection usually has no way of extending stack and/or
heap without identifying live data, and only a garbage collection cycle does that.

There is an approach called "mostly copying" garbage collection by Joel Bartlett
(at DEC), but to the best of my knowledge no current system implements it.  I
implemented it in a Scheme VM ages ago.

 > Why would I want to do that? I'm working on a benchmarking tool and I
 > don't want garbage collection to mess with my measured execution times. I run them multiple times and standard deviation goes way up because usually GC triggers during one run of n.
 > 
 > Any hints welcome + thanks

Just use spawn_opt to up the initial stack and heap size so that your test run
process doesn't need to GC.



More information about the erlang-questions mailing list