Created
January 22, 2014 16:42
-
-
Save PanosJee/8562181 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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