Compilation and how to check the final executable code - beam file (inline, dead code, optimization)

No, it doesn’t do it for public functions because it cannot do it for few reasons:

  • Due to late binding of Erlang functions and being able to add/replace modules at runtime it is not possible to be 100% sure that given function is and will not be used
  • In addition to above there is no way to detect unused functions even when you do not use runtime generated modules or IEx, the dynamic function calls via apply/3, spawn/3, spawn_link/3, etc. prevent you from doing such analysis. For example there is no way to detect that function start_link/1 in your GenServers is used, because it is fully dynamically called.