You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
690 B

  1. % This file is part of Jiffy released under the MIT license.
  2. % See the LICENSE file for more information.
  3. -module(jiffy_14_bignum_memory_leak).
  4. -include_lib("eunit/include/eunit.hrl").
  5. bignum_encoding_leak_test_() ->
  6. run_gc(),
  7. Before = erlang:memory(binary),
  8. encode_bignums(1000000),
  9. run_gc(),
  10. After = erlang:memory(binary),
  11. ?_assert(After - Before < 100000).
  12. run_gc() ->
  13. [erlang:garbage_collect(Pid) || Pid <- erlang:processes()].
  14. encode_bignums(N) ->
  15. {_, Ref} = spawn_monitor(fun() ->
  16. [jiffy:encode(1072502107250210725021072502) || _ <- lists:seq(1, N)]
  17. end),
  18. receive
  19. {'DOWN', Ref, process, _, _} ->
  20. ok
  21. end.