Based on this talk from @rvirding and in preparation for my upcoming ElixirConf talk, I’ve been purposefully trying to run into large binary space overflow problems. My hope is that doing so would help me show ways to diagnose it and, to some extent, treat it. Sadly, I can’t seem to expose the problem.
I tried code like this:
defmodule MemoryLeak do
def send_binaries(0), do: Process.sleep(:infinity)
def send_binaries(limit) do
pid = spawn(__MODULE__, :receive_and_leak, [ ])
big_binary = :crypto.strong_rand_bytes(1024 * 1024)
send(pid, big_binary)
send_binaries(limit - 1)
end
def receive_and_leak do
receive do
big_binary -> big_binary |> byte_size |> IO.puts
end
receive_and_leak
end
end
MemoryLeak.send_binaries(100_000)
I had hoped that the receiving processes wouldn’t garbage collect since they never do anything else, but I have seen memory dropping while it runs.
Does anyone know of some code I can use to see the issue?