Last active
June 23, 2025 18:22
Revisions
-
Bryan Hunt revised this gist
May 24, 2016 . 1 changed file with 17 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,6 @@ Inspired by [Stuff Goes Bad - Erlang in Anger](https://www.erlang-in-anger.com) >>Is the global process count indicative of a leak? If so, you may need to investigate unlinked processes, or peek inside supervisors’ children lists to see what may be weird-looking. ```elixir defmodule Diags do @@ -27,6 +25,16 @@ defmodule Diags do _ -> false end) end @doc """ Simplified version of the above function """ def list_non_linked_non_monitored_processes_simplified do for pid <- Process.list, pi <- [ Process.info(pid, [:links,:monitors,:registered_name]) ], [links: [], monitors: [], registered_name: registered_name ] <- [pi], do: {pid, registered_name} end end ``` @@ -46,3 +54,10 @@ iex(157)> Diags.list_non_linked_non_monitored_processes [{#PID<0.130.0>, [], [], []}, {#PID<0.1029.0>, [], [], []}, {#PID<0.1031.0>, [], [], []}] ``` Update - simplified the original function `list_non_linked_non_monitored_processes/0` ``` iex(190)> Diags.list_non_linked_non_monitored_processes [{#PID<0.130.0>, []}, {#PID<0.1029.0>, []}, {#PID<0.1031.0>, []}] ``` -
Bryan Hunt revised this gist
May 24, 2016 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,9 @@ Inspired by [Stuff Goes Bad - Erlang in Anger](https://www.erlang-in-anger.com) >>Is the global process count indicative of a leak? If so, you may need to investigate unlinked processes, or peek inside supervisors’ children lists to see what may be weird-looking. This implementation needs to be simplified: ```elixir -
Bryan Hunt revised this gist
May 24, 2016 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ Inspired by [Stuff Goes Bad - Erlang in Anger](https://www.erlang-in-anger.com) ```elixir defmodule Diags do -
Bryan Hunt revised this gist
May 24, 2016 . 2 changed files with 42 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ ```elixir defmodule Diags do @doc """ Generate a list of all processes in the system which are neither linked nor monitored. """ def list_non_linked_non_monitored_processes do Process.list |> Enum.map( fn pid -> {pid, Process.info( pid, [:links,:monitors,:registered_name])} end) |> Enum.map( fn {pid, words} -> {pid, Keyword.get(words,:links), Keyword.get(words,:monitors), Keyword.get(words,:registered_name) } end ) |> Enum.filter(fn {_,[],[],_} -> true _ -> false end) end end ``` ``` iex(153)> idler = fn -> receive do x -> IO.puts("#{inspect x}") end end #Function<20.50752066/0 in :erl_eval.expr/5> iex(154)> Diags.list_non_linked_non_monitored_processes [{#PID<0.130.0>, [], [], []}] iex(155)> spawn(idler) #PID<0.1029.0> iex(156)> spawn(idler) #PID<0.1031.0> iex(157)> Diags.list_non_linked_non_monitored_processes [{#PID<0.130.0>, [], [], []}, {#PID<0.1029.0>, [], [], []}, {#PID<0.1031.0>, [], [], []}] ``` -
Bryan Hunt revised this gist
May 24, 2016 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,6 @@ defmodule Diags do Generate a list of all processes in the system which are neither linked nor monitored. """ def list_non_linked_non_monitored_processes do Process.list |> Enum.map( fn pid -> {pid, Process.info( pid, [:links,:monitors,:registered_name])} end) |> Enum.map( @@ -15,8 +14,8 @@ defmodule Diags do } end ) |> Enum.filter(fn {_,[],[],_} -> true _ -> false end) end end -
Bryan Hunt created this gist
May 24, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ defmodule Diags do @doc """ Generate a list of all processes in the system which are neither linked nor monitored. """ def list_non_linked_non_monitored_processes do Process.list |> Enum.map( fn pid -> {pid, Process.info( pid, [:links,:monitors,:registered_name])} end) |> Enum.map( fn {pid, words} -> {pid, Keyword.get(words,:links), Keyword.get(words,:monitors), Keyword.get(words,:registered_name) } end ) |> Enum.filter(fn {_,nil,nil_} -> true {_,links,monitors,_} -> false end) end end