---
title: "ViewCompositionStrategy"
description: "A strategy for managing the underlying Composition of Compose UI [View]s such as [ComposeView]
and [AbstractComposeView]. See [AbstractComposeView.setViewCompositionStrategy].

Compose views involve ongoing work and registering the composition with external event sources.
These registrations can cause the composition to remain live and ineligible for garbage
collection for long after the host View may have been abandoned. These resources and
registrations can be released manually at any time by calling
[AbstractComposeView.disposeComposition] and a new composition will be created automatically when
needed. A [ViewCompositionStrategy] defines a strategy for disposing the composition
automatically at an appropriate time.

By default, Compose UI views are configured to [Default]."
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

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



```kotlin
interface ViewCompositionStrategy
```


A strategy for managing the underlying Composition of Compose UI `View`s such as `ComposeView`
and `AbstractComposeView`. See `AbstractComposeView.setViewCompositionStrategy`.

Compose views involve ongoing work and registering the composition with external event sources.
These registrations can cause the composition to remain live and ineligible for garbage
collection for long after the host View may have been abandoned. These resources and
registrations can be released manually at any time by calling
`AbstractComposeView.disposeComposition` and a new composition will be created automatically when
needed. A `ViewCompositionStrategy` defines a strategy for disposing the composition
automatically at an appropriate time.

By default, Compose UI views are configured to `Default`.


## Functions

```kotlin
fun installFor(view: AbstractComposeView): () -> Unit
```


Install this strategy for `view` and return a function that will uninstall it later. This
function should not be called directly; it is called by
`AbstractComposeView.setViewCompositionStrategy` after uninstalling the previous strategy.



