Skip to content

Instantly share code, notes, and snippets.

@PanosJee
Created January 22, 2014 16:42
Show Gist options
  • Save PanosJee/8562181 to your computer and use it in GitHub Desktop.
Save PanosJee/8562181 to your computer and use it in GitHub Desktop.
init([]) ->
% Start the scheduled GC job every minute. Naive!
erlang:send_after(60 * 1000, self(), {gc}),
{ok, no_state}.
handle_info({gc}, State) ->
case erlang:memory(binary) of
% We use more than 500 MB of binary space
Binary when Binary > 500000000 ->
erlang:garbage_collect(self())
_ ->
ok
end,
erlang:send_after(60 * 1000, self(), {gc}),
{noreply, State}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment