       tracer = start_tracer(self())
 
       try do
-        _ = measure_memory(fun, tracer)
+        _ = measure_memory(fun, tracer, parent)
         word_size = :erlang.system_info(:wordsize)
         memory_used = get_collected_memory(tracer)
         send(parent, {ref, memory_used * word_size})

      :ready_to_begin -> nil
    end

    fun.()
    :erlang.garbage_collect()
    send(tracer, :end_collection)


    ref = make_ref()
    Process.flag(:trap_exit, true)
    start_runner(fun, ref)
    await_results(nil, ref)
  end

  defp await_results(return_value, ref) do
    receive do
      {^ref, memory_usage} ->
        return_memory({memory_usage, return_value})

      {^ref, :shutdown} ->
        nil

      # we need a really basic pattern here because sending anything other than
      # just what's returned from the function that we're benchmarking will
      # involve allocating a new term, which will skew the measurements.
      # We need to be very careful to always send the `ref` in every other
      # message to this process.
      new_result ->
        await_results(new_result, ref)
    end
  end

