LeakCanary detects leaks which belong to official Android/Jetpack lifecycles.
With KTP, we may define our own instances management system with a scope-tree.
When we open and close scopes, a lifecycle is then derived for every instance of the app. Nevertheless, dev can add code that trigger leaks, and even if the scope is closed and the instance is not injectable anymore, the instance is still there because of a leak.
LeakCanary supports custom lifecycle watcher, where we can tell it to watch if an instance will be soon garbage collected with :
AppWatcher.objectWatcher.watch(viewAdapter, "the view adapter should be destroyed")
Is there a way to retrieve all instances that belong to a scope at runtime ? To enable an automatic verification of the leak less instances ? that could be at the end looking like this ?
KTP.openScope(this).getScopedInstances().forEach {
AppWatcher.objectWatcher.watch(it, "the instance ${it.instance} of the class ${it.class.name} should be destroyed")`
}
LeakCanary detects leaks which belong to official Android/Jetpack lifecycles.
With KTP, we may define our own instances management system with a scope-tree. When we open and close scopes, a lifecycle is then derived for every instance of the app. Nevertheless, dev can add code that trigger leaks, and even if the scope is closed and the instance is not injectable anymore, the instance is still there because of a leak.
LeakCanary supports custom lifecycle watcher, where we can tell it to watch if an instance will be soon garbage collected with :
AppWatcher.objectWatcher.watch(viewAdapter, "the view adapter should be destroyed")
Is there a way to retrieve all instances that belong to a scope at runtime ? To enable an automatic verification of the leak less instances ? that could be at the end looking like this ?