Skip to content

Instantly share code, notes, and snippets.

@rozap
Created March 29, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozap/a1e170f1058d7e528d0b95b3570c8dee to your computer and use it in GitHub Desktop.
Save rozap/a1e170f1058d7e528d0b95b3570c8dee to your computer and use it in GitHub Desktop.
def print_mem(label) do
case :erlang.process_info(self, :binary) do
{:binary, bins} ->
{size, count} = Enum.reduce(bins, {0, 0}, fn {_bid, size, count}, {s, c} -> {size + s, count + c} end)
Logger.warn("#{label} usage in #{__MODULE__} is #{size / 1000000}mb, #{count} of them")
_ -> :ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment