AppWatcher

object AppWatcher

The entry point API for using ObjectWatcher in an Android app. AppWatcher.objectWatcher is in charge of detecting retained objects, and AppWatcher is auto configured on app start to pass it activity and fragment instances. Call ObjectWatcher.watch on objectWatcher to watch any other object that you expect to be unreachable.

Types

Config
Link copied to clipboard
data class Config(watchActivities: Boolean, watchFragments: Boolean, watchFragmentViews: Boolean, watchViewModels: Boolean, watchDurationMillis: Long, enabled: Boolean)

Functions

appDefaultWatchers
Link copied to clipboard
fun appDefaultWatchers(application: Application, reachabilityWatcher: ReachabilityWatcher = objectWatcher): List<InstallableWatcher>

Creates a new list of default app InstallableWatcher, created with the passed in reachabilityWatcher (which defaults to objectWatcher). Once installed, these watchers will pass in to reachabilityWatcher objects that they expect to become weakly reachable.

manualInstall
Link copied to clipboard
fun manualInstall(application: Application, retainedDelayMillis: Long = TimeUnit.SECONDS.toMillis(5), watchersToInstall: List<InstallableWatcher> = appDefaultWatchers(application))

Enables usage of AppWatcher.objectWatcher which will expect passed in objects to become weakly reachable within retainedDelayMillis ms and if not will trigger LeakCanary (if LeakCanary is in the classpath).

Properties

config
Link copied to clipboard
var config: AppWatcher.Config
isInstalled
Link copied to clipboard
val isInstalled: Boolean
objectWatcher
Link copied to clipboard
val objectWatcher: ObjectWatcher

The ObjectWatcher used by AppWatcher to detect retained objects. Only set when isInstalled is true.

retainedDelayMillis
Link copied to clipboard
var retainedDelayMillis: Long