<div class='sourceset sourceset-android'>Android</div>

```kotlin
object DisposeOnDetachedFromWindow : ViewCompositionStrategy
```

[ViewCompositionStrategy](/jetpack-compose/androidx.compose.ui/ui/interfaces/ViewCompositionStrategy) that disposes the composition whenever the view becomes detached
from a window. If the user of a Compose UI view never explicitly calls
[AbstractComposeView.createComposition](/jetpack-compose/androidx.compose.ui/ui/classes/AbstractComposeView), this strategy is always safe and will always clean
up composition resources with no explicit action required - just use the view like any other
View and let garbage collection do the rest. (If [AbstractComposeView.createComposition](/jetpack-compose/androidx.compose.ui/ui/classes/AbstractComposeView) is
called while the view is detached from a window, [AbstractComposeView.disposeComposition](/jetpack-compose/androidx.compose.ui/ui/classes/AbstractComposeView)
must be called manually if the view is not later attached to a window.)