[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [LeakDetector](https://evolu.dev/docs/api-reference/common/LeakDetector) › TestLeakDetector

Defined in: [packages/common/src/LeakDetector.ts:121](https://github.com/evoluhq/evolu/blob/a18269a1b822c670b507c6a9b73b23eed32551fe/packages/common/src/LeakDetector.ts#L121)

Test [LeakDetector](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/LeakDetector) with deterministic collection.

## See

[testCreateLeakDetector](https://evolu.dev/docs/api-reference/common/LeakDetector/functions/testCreateLeakDetector)

## Extends

- [`LeakDetector`](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/LeakDetector)

## Properties

<a id="collect"></a>

### collect

```ts
readonly collect: () => number;
```

Defined in: [packages/common/src/LeakDetector.ts:128](https://github.com/evoluhq/evolu/blob/a18269a1b822c670b507c6a9b73b23eed32551fe/packages/common/src/LeakDetector.ts#L128)

Simulates garbage collection of all tracked targets.

Reports every tracked handle that is still held and clears tracking.
Returns the number of reported leaks.

### getTrackedCount

```ts
readonly getTrackedCount: (options?: {
  name?: string;
}) => number;
```

Defined in: [packages/common/src/LeakDetector.ts:131](https://github.com/evoluhq/evolu/blob/a18269a1b822c670b507c6a9b73b23eed32551fe/packages/common/src/LeakDetector.ts#L131)

Returns the number of currently tracked targets.

### track

```ts
readonly track: (target: object, leak: Leak, unregisterToken: object) => void;
```

Defined in: [packages/common/src/LeakDetector.ts:35](https://github.com/evoluhq/evolu/blob/a18269a1b822c670b507c6a9b73b23eed32551fe/packages/common/src/LeakDetector.ts#L35)

Starts tracking `target` until [untrack](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/LeakDetector#untrack) or
garbage collection.

When `target` is garbage-collected and [Leak.isLeaked](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/Leak#isleaked) returns `true`,
the leak is reported with the stack captured at this call. The leak must
not reference `target`, or the target would never become unreachable.

#### Inherited from

[`LeakDetector`](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/LeakDetector).[`track`](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/LeakDetector#track)

---

<a id="untrack"></a>

### untrack

```ts
readonly untrack: (unregisterToken: object) => void;
```

Defined in: [packages/common/src/LeakDetector.ts:38](https://github.com/evoluhq/evolu/blob/a18269a1b822c670b507c6a9b73b23eed32551fe/packages/common/src/LeakDetector.ts#L38)

Stops tracking the target registered with `unregisterToken`.

#### Inherited from

[`LeakDetector`](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/LeakDetector).[`untrack`](https://evolu.dev/docs/api-reference/common/LeakDetector/interfaces/LeakDetector#untrack)