For the complete documentation index, see llms.txt. This page is also available as Markdown.

Releasing Ad Instance Resources

After an ad shows, DT recommends releasing the resources used to show it. Releasing ad instance resources ensures efficient memory usage, prevents resource leaks, and supports proper lifecycle management.

Release the ad instance when:

  • The app destroys the hosting screen or component.

  • The ad no longer runs in the current session.

  • The screen containing the ad is no longer visible.

  • A new ad instance replaces the existing one.

The following example removes all views from the ad container and destroys the ad instance.

Java
if (adContainer != null) {
adContainer.removeAllViews();
  adContainer = null;
}​​
if (mSpot != null) {
mSpot.destroy();
  mSpot = null;
}
Kotlin
adContainer?.removeAllViews()
adContainer = null

mSpot?.destroy()
mSpot = null

Last updated