Skip to content

Instantly share code, notes, and snippets.

@redink
Created September 11, 2019 22:11
Show Gist options
  • Save redink/10130c314180a2d0effa570c25ab8266 to your computer and use it in GitHub Desktop.
Save redink/10130c314180a2d0effa570c25ab8266 to your computer and use it in GitHub Desktop.
defmodule T do
# refc binary
def test do
for _ <- 1..600, do: spawn fn -> start() end
end
defp start do
me = self()
Process.spawn(fn -> handle_big_binary(me) end, [])
receive do
{:ok, value} ->
:timer.sleep(1000000)
value
end
end
defp handle_big_binary(master_pid) do
big_binary = :binary.copy(<<1>>, 20 * 1024 * 1024)
<<small_binary::size(1)-binary, _::binary>> = big_binary
# Process.send(master_pid, {:ok, :binary.copy(small_binary)}, [])
Process.send(master_pid, {:ok, small_binary}, [])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment