Skip to content

Instantly share code, notes, and snippets.

@binarin
Created July 3, 2015 14:37
Show Gist options
  • Save binarin/b1fd1c0b8183250787f6 to your computer and use it in GitHub Desktop.
Save binarin/b1fd1c0b8183250787f6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env escript
make_big_term() ->
Reused = lists:seq(1, 10000),
[ Reused || _ <- lists:seq(1, 1000) ].
main([]) ->
Term = make_big_term(),
io:format("PARENT: ~p - ~p~n", [byte_size(term_to_binary(Term)), erlang:process_info(self(), memory)]),
spawn(fun() ->
io:format("CHILD: ~p - ~p~n", [byte_size(term_to_binary(Term)), erlang:process_info(self(), memory)]),
erlang:garbage_collect(),
io:format("CHILG: ~p - ~p~n", [byte_size(term_to_binary(Term)), erlang:process_info(self(), memory)])
end),
erlang:garbage_collect(),
io:format("PARENG: ~p - ~p~n", [byte_size(term_to_binary(Term)), erlang:process_info(self(), memory)]),
timer:sleep(3000).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment