# `Alternera.Plugin.Provisional.HeapPeak.Collector`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_plugin_sdk/lib/alternera/plugin/provisional/heap_peak/collector.ex#L1)

The one process the node's metered steps report their garbage
collections to (`Plugin.Provisional.HeapPeak`). It owns one trace
session for as long as it lives and is that session's tracer: putting a
process under a meter turns the session's `:garbage_collection` trace on
for that process, and stopping the meter turns it off, each a few
microseconds. A session per meter cost about 15 ms a step to take down
(`:trace.session_destroy/1`, measured with 5,300 modules loaded).

It keeps, per meter, the process watched, the largest size a collection
reported and a monitor of the meter's owner: a meter whose owner goes is
dropped and its process's trace turned off. A watched process that goes
keeps its meter, since the peak of a process killed at its limit is read
after it died.

Restarted, it has a new session and no meters: a meter started before
reads 0, and its process, traced on a session that is gone, sends
nothing.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `now`

```elixir
@spec now(reference(), non_neg_integer()) :: :ok
```

Hands the meter `ref` a size of its process, in bytes.

# `stop`

```elixir
@spec stop(reference()) :: {non_neg_integer(), pid()} | :none
```

Ends the meter `ref`: the largest size it saw, in bytes, and the process
it watched; `:none` for a meter that watched nothing.

# `watch`

```elixir
@spec watch(reference(), pid(), pid()) :: :ok
```

Puts `pid` under the meter `ref` of `owner`, returning once its
collections are traced.

# `watching`

```elixir
@spec watching() :: non_neg_integer()
```

How many meters are watching a process now.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
