I am using Leak Canary to track memory leak and it says the following were leaked:
static hk.o
references ht.a
leaks MainActivity instance
what is the hk.o
and ht.a
? I dont have them in my MainActivity.
I am using Leak Canary to track memory leak and it says the following were leaked:
static hk.o
references ht.a
leaks MainActivity instance
what is the hk.o
and ht.a
? I dont have them in my MainActivity.
I tracked this down, and the culprit is Google Ads. The classes you mentioned are actually from the library
com.google.ads.interactivemedia.v3:interactivemedia
, which is included withplay-services-ads
.The reference to the activity was set via the constructor of
PublisherAdView
, where I passed the activity context. Probably you are also using a similar ad view in your app.As a workaround, I now pass the application context to the ad view, which seems to have solved the leak:
I think those are pro guarded (renamed classes with random names to prevent reverse engineering) of any one of the dependencies. I have seen this when stuff related like Google Sign In is used in the app.
Google Services classes are generally Pro Guarded.
I hope this helps.
Those classes are third party library classes . You may take your MainActivity instance as an argument and pass in which class's instance belong to library. You could use ApplicationContext as an argument if it's not necessary to pass in Activity.