@Override public void onCreate() { super.onCreate(); if (LeakCanary.isInAnalyzerProcess(this)) { // This process is dedicated to LeakCanary for heap analysis. // You should not init your app in this process. return; } LeakCanary.install(this); } }
@Override public final void testFinished(Description description) { detectLeaks(); LeakCanary.installedRefWatcher().clearWatchedReferences(); }
private void initializeLeakDetection() { if (BuildConfig.DEBUG) { LeakCanary.install(this); } } }
@Override protected boolean isDisabled() { return LeakCanary.isInAnalyzerProcess(context); }
@Override public void onCreate() { super.onCreate(); LeakCanary.install(this); } }
@Override public void onCreate() { super.onCreate(); if (LeakCanary.isInAnalyzerProcess(this)) { // This process is dedicated to LeakCanary for heap analysis. // You should not init your app in this process. return; } refWatcher = installLeakCanary(); app = this; // Initialize settings first because others inits can use its values SettingsActivity.initSettings(this); NewPipe.init(getDownloader(), org.schabi.newpipe.util.Localization.getPreferredExtractorLocal(this)); StateSaver.init(this); initNotificationChannel(); // Initialize image loader ImageLoader.getInstance().init(getImageLoaderConfigurations(10, 50)); configureRxJavaErrorHandler(); // Check for new version new CheckForNewAppVersionTask().execute(); }
private void configureLeakCanary() { if (LeakCanary.isInAnalyzerProcess(this)) { return; } LeakCanary.install(this); } }
@Override public void onCreate() { super.onCreate(); LeakCanary.install(this); } }
@Override public void onCreate(@NonNull Application application) { if (LeakCanary.isInAnalyzerProcess(application)) { // This process is dedicated to LeakCanary for heap analysis. // You should not init your app in this process. return; } //使用 RetrofitUrlManager 切换 BaseUrl RetrofitUrlManager.getInstance().putDomain(GANK_DOMAIN_NAME, GANK_DOMAIN); //当所有模块集成到宿主 App 时, 在 App 中已经执行了以下代码 if (BuildConfig.IS_BUILD_MODULE) { //leakCanary内存泄露检查 ArmsUtils.obtainAppComponentFromContext(application).extras() .put(IntelligentCache.getKeyOfKeep(RefWatcher.class.getName()) , BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED); } }
@Test public void detectsLeak() { leaking = new Date(); RefWatcher refWatcher = LeakCanary.installedRefWatcher(); refWatcher.watch(leaking); InstrumentationLeakDetector leakDetector = new InstrumentationLeakDetector(); InstrumentationLeakResults results = leakDetector.detectLeaks(); if (results.detectedLeaks.size() != 1) { throw new AssertionError("Expected exactly one leak, not " + results.detectedLeaks.size()); } InstrumentationLeakResults.Result firstResult = results.detectedLeaks.get(0); String leakingClassName = firstResult.analysisResult.className; if (!leakingClassName.equals(Date.class.getName())) { throw new AssertionError("Expected a leak of Date, not " + leakingClassName); } } }
/** * use LeakCanary to check mey leak */ private void initLeakCanary() { if (LeakCanary.isInAnalyzerProcess(this)) { // This process is dedicated to LeakCanary for heap analysis. // You should not init your app in this process. return; } LeakCanary.install(this); }
@Override public void onCreate() { super.onCreate(); refWatcher = LeakCanary.install(this); }
private void initializeLeakCanary() { if (LeakCanary.isInAnalyzerProcess(this)) { return; } //refWatcher = LeakCanary.install(this); }
@After public void tearDown() { LeakCanary.installedRefWatcher().clearWatchedReferences(); }
protected void setupLeakCanary() { enabledStrictMode(); if (LeakCanary.isInAnalyzerProcess(this)) { // This process is dedicated to LeakCanary for heap analysis. // You should not init your app in this process. return; } LeakCanary.install(this); }
@Override public void onCreate() { super.onCreate(); refWatcher = LeakCanary.install(this); } }
@After public void tearDown() { LeakCanary.installedRefWatcher().clearWatchedReferences(); }
@Override public void onCreate() { super.onCreate(); if (LeakCanary.isInAnalyzerProcess(this)) { return; } LeakCanary.install(this); } }
@Override public void onCreate() { super.onCreate(); if (_instance == null) { LeakCanary.install(this); _instance = this; Logger.setDebug(BuildConfig.DEBUG); } }
@Before public void setUp() { LeakCanary.installedRefWatcher().clearWatchedReferences(); }