Search code examples
androidmemory-leaksacraleakcanary

ACRA and LeakCanary


A recent I begin use LeakCanary. And I Here is my stacktrace:

com.my.app.ui.menu.MenuActivity has leaked:
D/LeakCanary: * GC ROOT static org.acra.ACRA.errorReporterSingleton
D/LeakCanary: * references org.acra.ErrorReporter.lastActivityCreated
D/LeakCanary: * leaks com.my.app.ui.menu.MenuActivity instance

If I correctly understand, MenuActivity contatins static reference on the field errorReporterSingleton, right? How I can resolve this leak?


Solution

  • LeakCanary appearas to be telling to that org.acra.ErrorReporter.lastActivityCreated is holding a reference to com.my.app.ui.menu.MenuActivity.

    LeakCanary is mistaken.

    lastActivityCreated is a weak reference to the last Activity. Ie it will released when there are no strong/direct references.