Skip to content

Commit

Permalink
Spawn a process to collect garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmi committed Jun 9, 2024
1 parent fd5024a commit e7adec8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/composite.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ defmodule Strom.Composite do
@impl true
def handle_call({:call, init_flow}, _from, %__MODULE__{} = composite) do
flow = reduce_flow(composite.components, init_flow)

collect_garbage(composite)
{:reply, flow, composite}
end

Expand Down Expand Up @@ -195,7 +195,12 @@ defmodule Strom.Composite do
end

defp collect_garbage(%Strom.Renamer{}), do: :nothing
defp collect_garbage(component), do: :erlang.garbage_collect(component.pid)

defp collect_garbage(component) do
spawn(fn ->
:erlang.garbage_collect(component.pid)
end)
end

defp pid_postfix do
to_string(:erlang.pid_to_list(self()))
Expand Down

0 comments on commit e7adec8

Please sign in to comment.