Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Elixir have a garbage collector?

Tags:

elixir

I've started reading about the Elixir programming language.

I understand that:

  1. It is Functional
  2. It is dynamic but support @spec
  3. It is based on Erlang VM

My question is: Does it have a sort of GC?

like image 528
Gian Lorenzo Meocci Avatar asked Apr 20 '15 19:04

Gian Lorenzo Meocci


People also ask

Why is garbage collection important in Elixir?

If there isn't enough space in memory to put new information, garbage collection is launched. It removes data that's no longer necessary for the app to work, and then the app resumes. Erlang uses GC that separate objects in the heap into two categories: long-term and short-term.

Does Erlang have a garbage collector?

Erlang has a copying semi-space garbage collector. This means that when doing a garbage collection, the terms are copied from one distinct area, called the from space, to a new clean area, called the to space. The collector starts by scanning the root-set (stack, registers, etc).

Does Visual Studio have garbage collection?

To force a garbage collection, use the hotkey: Ctrl+Alt+Shift+F12, Ctrl+Alt+Shift+F12 (press it twice). If forcing garbage collection reliably makes your scenario work, file a report through the Visual Studio feedback tool as this behavior is likely to be a bug.


1 Answers

Yes, Erlang has GC, and since Elixir is built on Erlang it too has GC. See this old SO answer about Erlang GC and this one. The Elixir site refers to GC as follows:

Due to their lightweight nature, it is not uncommon to have hundreds of thousands of processes running concurrently in the same machine. Isolation allows processes to be garbage collected independently, reducing system-wide pauses, and using all machine resources as efficiently as possible (vertical scaling).

like image 64
Chase Avatar answered Oct 07 '22 03:10

Chase