0
votes

In python if I'm playing around with the REPL I can force garbage collection with import gc; gc.collect(). How do I do the same with Elixir's iex REPL?

Example before large variable binding:

enter image description here

So around 700M of RAM used and 300M of swap.

After large data binding to variable xx (fetches 500 timeseries of 7000 structs each from database):

enter image description here

So now around 2.2G used with 500M swap. Now rebinding xx to something small:

enter image description here

But memory used hasn't really changed. Still 2.2G RAM and around 500M of swap. However if I quit IEX: enter image description here

Back to under 400M of RAM used. So the big data binding which was re-bound, wasn't garbage collected within iex. How can I force it to do so?

1

1 Answers

2
votes

There's info about this here: https://erlang.org/doc/apps/erts/GarbageCollection.html

Maybe just try doing:

:erlang.garbage_collect()