Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Merciful killer for your Erlang processes
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

euthanasia is a merciful killer for your Erlang processes

Basic usage

Start euthanasia application:


Register process in the list:


You can also call


to register the currently running process.

If the process' queue grows too large, euthanasia will kill it

If the process' total memory grows too large, euthanasia tries to garbage collect it first, then kills it if garbage collecting doesn't help

NOTE: euthanasia doesn't restart processes, it's supervisors' job. So, make sure you've taken care about the process' restart strategy if it needs to be restarted.

Unregistering process and stopping its monitoring:


Advanced options:

euthanasia:register(Pid, [{Option1, Value1}, {Option2, Value2}])

Maximum queue length (default value is 100):

{max_queue_length, 10}

Process check interval (default value is 1000 milliseconds):

{interval, 100}

NOTE: use with care, too frequent process checks may cause too much load

Maximum memory before garbage collecting, in bytes (default value is 20971520, i.e. 20MB):

{max_memory, 102400}

Number of forced garbage collection attempts before killing it and non-zero interval between these attempts, in milliseconds; 0 attempts means no forced garbage collecting for this process (default {2, 1000}):

{gc_attempts, {Attempts, Interval}}

Process pre-kill hook. You can log some extended process information here, or even save its queue for further reuse, or whatever else. Function with arity 1 that accepts the pid as an argument (in a {Module, Function} format or just a lambda) and a maximum timeout to perform the hook before force-killing the process. Default value is 'undefined', i.e. no hook at all:

{pre_kill_hook, {{M, F}, Timeout}}

You can change default numbers by setting the same keys for euthanasia application environment variables, for example:

application:set_env(euthanasia, max_memory, 4096000)


  • Add docs and specs into the code
  • Add several more tests for better code coverage
Something went wrong with that request. Please try again.