---
url: https://cri-middleware.github.io/SSPlayerForReactNative/api/functions/ssCheckForLeaks.md
---
# Function: ssCheckForLeaks()

> **ssCheckForLeaks**(`source`, `options?`): `Promise`<[`SsLeakCheckResult`](../interfaces/SsLeakCheckResult.md)>

Defined in: [packages/react-native-spritestudio/src/player/leakCheck.ts:63](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/player/leakCheck.ts#L63)

Loads and disposes `source` `cycles` times and reports whether the native
handle counts came back to where they started.

This is the "no leaked native handles" criterion, made runnable.
It drives the same L3 path `<SpriteStudioView>` drives on mount and unmount —
`load()` then `dispose()` — so what it proves is the real teardown, not a
synthetic one.

**The comparison is exact, and that is only true because `dispose()` releases
eagerly.** Both Hybrid Objects override Nitro's `dispose()` (which is a no-op
unless a class does), so the Brain handles are given back inside the call
rather than whenever the collector next runs. A count that has not come back
down by the time this returns is therefore a leak and not a pending GC.

Growth rather than inequality, because an app is free to be doing other things
on other players while this runs; a count that *fell* is someone else's
teardown landing mid-check, which is not a failure.

## The caches have to be drained first

`ssResourceCache` keeps a pack alive for as long as something holds a lease,
and `preload` holds one nothing balances. Both are correct and both are
indistinguishable from a leak when the measurement is a count of live
handles: the baseline would be taken before the first cycle warmed the cache
and the reading after it would be one resource higher, every time, on a
player that leaks nothing. So the caches are emptied **before the baseline**
and again at the end, which also leaves the app where it found it.

## Parameters

### source

[`SsSource`](../type-aliases/SsSource.md)

### options?

#### animation?

`string`

#### cycles?

`number`

## Returns

`Promise`<[`SsLeakCheckResult`](../interfaces/SsLeakCheckResult.md)>
