# Watchdog Terminations | Sentry for tvOS

This integration is available since version 8.0.0 of Sentry Apple SDK. It was named<!-- --> <!-- -->[Out of Memory](https://docs.sentry.io/platforms/apple/guides/tvos/configuration/out-of-memory.md) <!-- -->before the 8.0.0 release.

This integration tracks [watchdog terminations](https://developer.apple.com/documentation/xcode/addressing-watchdog-terminations.md) based on heuristics. This feature is available for iOS, tvOS, and Mac Catalyst, works only if the application was in the foreground, and doesn't track watchdog terminations for unit tests.

When a typical unhandled error occurs, the Apple SDK writes a report to disk before the app terminates. It includes the current state of your application with details like the stack trace, tags, breadcrumbs, and so on.

The watchdog terminates your app without notice, which means the SDK can't write a report to disk. A common reason for the watchdog to terminate your app is an Out Of Memory problem.

Note, that there are some security-related types of crashes where the OS immediately terminates the app. These are usually infrequent, and include stack buffer overflows or exceptions with a termination reason related to code signing. Third-party libraries like Sentry can't report these incidents.

Those types of crashes can sometimes be visible in the [Xcode Organizer](https://developer.apple.com/documentation/xcode/acquiring-crash-reports-and-diagnostic-logs.md), though. If the app is terminated because it hangs, we won't create a watchdog termination event. An `AppHangs` event will be created instead.

As a result, in the Apple SDK, we track watchdog terminations during the app start based on heuristics, but getting the state of the app when a watchdog termination occurs is challenging. The SDK adds breadcrumbs to watchdog termination events by appending the breadcrumbs to an open file, which should have a marginal impact on your app's performance. Still, it skips adding some frequently changing context to avoid extra I/O, such as free memory, free storage, device orientation, charging status, battery level, etc.

When a user launches the app, the SDK checks the following statements and reports a watchdog termination if all of them are true:

* The app didn't crash on the previous run.
* The app was in the foreground/active.
* The user launched the app at least once. When your app was killed by the watchdog during the first launch, the SDK can't detect it.
* There was no debugger attached to the process of the app. (If there was, our logic would falsely report watchdog terminations whenever you restarted the app in development.)
* The app was not running on a simulator.
* The OS didn't update your app.
* The user didn't update the OS of their device.
* The user didn't terminate the app manually, and neither did the OS.

If you're interested in the implementation details, you can check out [the code](https://github.com/getsentry/sentry-cocoa/blob/main/Sources/Sentry/SentryWatchdogTerminationLogic.m) to find out more.

If you'd like to opt out of this feature, you can do so using options:

```swift
import Sentry

SentrySDK.start { options in
    options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
    options.enableWatchdogTerminationTracking = false
}
```

If you disable the `enableCrashHandler` option, the SDK will disable watchdog termination tracking. This will prevent false positive watchdog termination reporting for every crash.
