Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 261
Nicolas Avatar asked Feb 26 '17 03:02

Nicolas


People also ask

How do I stop LeakCanary?

This is what the Android documentation recommends. Disable the leakcanary launcher activity by setting the leak_canary_add_launcher_icon resource boolean to false.

How does a leak Canary work?

LeakCanary hooks into the Android lifecycle to automatically detect when activities and fragments are destroyed and should be garbage collected. These destroyed objects are passed to an ObjectWatcher , which holds weak references to them.

What is LeakCanary?

LeakCanary 🐤 LeakCanary is a memory leak detection library for Android. LeakCanary's knowledge of the internals of the Android Framework gives it a unique ability to narrow down the cause of each leak, helping developers dramatically reduce Application Not Responding freezes and OutOfMemoryError crashes.

What is root leak?

A root leak can be one of two things. It can be a single memory leak, or it can be the start of a leak cycle. A leak cycle occurs when you lose a reference to a group of objects. A memory leak leaks one object while a leak cycle leaks a group of objects.


2 Answers

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.

like image 101
Cyrus Avatar answered Sep 25 '22 10:09

Cyrus


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.

like image 43
Abhishek Avatar answered Sep 25 '22 10:09

Abhishek