Nicolas
Nicolas

Reputation: 291

MainActivity leaked using leakcanary

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.

Upvotes: 17

Views: 1242

Answers (3)

Daniel Zolnai
Daniel Zolnai

Reputation: 16910

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 with play-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:

new PublisherAdView(getContext().getApplicationContext())

Upvotes: 1

Abhishek
Abhishek

Reputation: 61

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.

Upvotes: 3

Cyrus
Cyrus

Reputation: 9425

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.

Upvotes: 3

Related Questions