Skip to content

Instantly share code, notes, and snippets.

@ferd
Last active March 22, 2024 08:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferd/6030877 to your computer and use it in GitHub Desktop.
Save ferd/6030877 to your computer and use it in GitHub Desktop.
-spec gc_count(non_neg_integer(), binary()) -> non_neg_integer().
gc_count(PreviousCounter, Bin) ->
case byte_size(Bin) of
N when N >= 64 -> % refc binary
Count = N + PreviousCounter
case Count >= ?THRESHOLD of
true ->
erlang:garbage_collect(),
0;
false ->
Count
end;
N -> % heap binary
PreviousCounter+N
end.
@Jasson
Copy link

Jasson commented Jan 20, 2014

The variable 'Count' is unused.
The variable 'NewCount' is unbound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment